Nix / NixOS

1732 readers
9 users here now

Main links

Videos

founded 1 year ago
MODERATORS
1
2
3
4
5
 
 

Homebrew is the most popular package manager on MacOS, and for good reason. However personally, I believe that Nix is more powerful.

6
 
 

edit: for the solution, see my comment below

I need/want to build aeson and its subproject attoparsec-aeson from source (it's a fork of the "official" aeson), but I'm stuck... can you help out?

The sources of attoparsec-aeson live in a subdirectory of the aeson ones, so I have the sources:

aeson-src = fetchFromGitHub {
  ...
};

and the "main" aeson library:

aeson = haskellPackages.mkDerivation {
  pname = "aeson";
  src = aeson-src;
  ...
};

When I get to attoparsec-aeson however I run into a wall: I tried to follow the documentation about sourceRoot:

attoparsec-aeson = haskellPackages.mkDerivation {
  pname = "attoparsec-aeson";
  src = aeson-src;
  sourceRoot = "./attoparsec-aeson"; # maybe this should be "${aeson-src}/attoparsec-aeson"?
                                     # (it doesn't work either way)
  ...
};

but I get

 error: function 'anonymous lambda' called with unexpected argument 'sourceRoot'

Did I fail to spot some major blunder (I am nowhere near an expert)? Does sourceRoot not apply to haskellPackages.mkDerivation? What should I do to make it work?

BTW:

IDK if this may cause issues, but the attoparsec-aeson sources include symlinks to files in the "main" attoparsec sources:

~/git-clone-of-attoparsec-sources $ tree attoparsec-aeson/
attoparsec-aeson/
├── src
│   └── Data
│       └── Aeson
│           ├── Internal
│           │   ├── ByteString.hs -> ../../../../../src/Data/Aeson/Internal/ByteString.hs
│           │   ├── Text.hs -> ../../../../../src/Data/Aeson/Internal/Text.hs
│           │   └── Word8.hs -> ../../../../../src/Data/Aeson/Internal/Word8.hs
│           ├── Parser
│           │   └── Internal.hs
│           └── Parser.hs
├── attoparsec-aeson.cabal
└── LICENSE
7
8
9
10
 
 

I believe I solved this problem before, but I can't find the solution again. I have some Flatpaks installed on my NixOS system, but they aren't showing up in the app menu. Does anyone know what might be causing this or how to fix it?

11
 
 
12
 
 
13
23
submitted 1 month ago* (last edited 1 month ago) by [email protected] to c/[email protected]
14
 
 

I'm trying to set up a simple script (linked to a hotkey in my window manager) that can launch a terminal window with a nix-shell containing packages I specify. So far, I got this:

set packages (fuzzel -d --lines 0 --prompt 'packages for nix-shell > ')
kitty nix-shell --packages $packages --run fish

If I type a single package into my runlauncher (fuzzel) (e.g. grim), the window spawns with a nix-shell as expected; if, however, I attempt to launch a shell with multiple packages (e.g. grim slurp), it fails to launch with the following error:

error:
       … while calling the 'derivationStrict' builtin

         at /builtin/derivation.nix:9:12: (source not available)

       … while evaluating derivation 'shell'
         whose name attribute is located at /nix/store/cjz8w4dgc3rd2n3dqv5c208vygndjyba-source/pkgs/stdenv/generic/make-derivation.nix:336:7

       … while evaluating attribute 'buildInputs' of derivation 'shell'

         at /nix/store/cjz8w4dgc3rd2n3dqv5c208vygndjyba-source/pkgs/stdenv/generic/make-derivation.nix:383:7:

          382|       depsHostHost                = elemAt (elemAt dependencies 1) 0;
          383|       buildInputs                 = elemAt (elemAt dependencies 1) 1;
             |       ^
          384|       depsTargetTarget            = elemAt (elemAt dependencies 2) 0;

       error: attempt to call something which is not a function but a set

       at «string»:1:107:

            1| {...}@args: with import <nixpkgs> args; (pkgs.runCommandCC or pkgs.runCommand) "shell" { buildInputs = [ (grim slurp) ]; } ""
             |                                                                                                           ^

This happens with or without launching a new kitty window, and it happens with other runlaunchers as well. Why on earth isn't this working?

Any help appreciated---thanks, everyone.

15
 
 
16
17
 
 
18
19
20
 
 
21
 
 

cross-posted from: https://discuss.tchncs.de/post/22368053

NixOS Facter aims to be an alternative to projects such as NixOS Hardware and nixos-generate-config. It solves the problem of bootstrapping NixOS configurations by deferring decisions about hardware and other aspects of the target platform to NixOS modules.

22
11
submitted 1 month ago* (last edited 1 month ago) by [email protected] to c/[email protected]
 
 

Maaaybe a stupid question as it might just be the same thing done differently. I'm not bright enough to understand the differences.

hardware.graphics was recently introduced which replaced hardware.opengl. Now, I've got my amdvlk, libva and such configured via hardware.graphics — recently I came across hardware.amdgpu which offers a bunch of options.

Should one combine, use one or the other, or does it make any difference at all?

hardware.amdgpu.opencl.enable
hardware.amdgpu.legacySupport.enable
hardware.amdgpu.initrd.enable
hardware.amdgpu.amdvlk.supportExperimental.enable
hardware.amdgpu.amdvlk.support32Bit.package
hardware.amdgpu.amdvlk.support32Bit.enable
hardware.amdgpu.amdvlk.settings
hardware.amdgpu.amdvlk.package
hardware.amdgpu.amdvlk.enable
hardware.graphics.extraPackages32
hardware.graphics.extraPackages
hardware.graphics.enable32Bit
hardware.graphics.enable

That is, are these two examples the same for all intents and purposes or do either bring anything else?

hardware.amdgpu.amdvlk = {
  enable = true;
  support32Bit.enable = true;
};

# VS.

hardware.graphics = {
  enable = true;
  enable32Bit = true;
  extraPackages = with pkgs; [
    amdvlk
  ];
  extraPackages32 = with pkgs; [
    driversi686Linux.amdvlk
  ];
};
23
 
 

Title says it all. The Determinate Systems installer is supposed to have support, but it doesn’t work – from what I can tell, the contexts are wrong. Running restorecon reports changes, but I’m still getting denials. Running on Fedora Asahi Remix 40, if that’s relevant.

Is there any way to make this work? AppArmor is unsupported on Fedora, so I can’t switch to it…

24
4
submitted 2 months ago* (last edited 2 months ago) by [email protected] to c/[email protected]
 
 

Hi all;

This is a bit of a long shot; but I'm having an issue with trying to modularize my config in preparation for a new laptop.

In particular the issue I have is around passing a path through to an import statement for a home-managed user.

In particular I'm getting undefinedVariable hmPath; but it doesn't seem to be having the same issue when I'm mapping groups and shell; so I can only assume that imports has to be treated differently but I'm at a loss.

Any help on what I've misunderstood would be greatly appreciated.

Snippet below

{ pkgs, config, options, lib, home-manager, ... }:

with lib; let
  cfg = config.ltp.home;

  user = types.submodule ({name, ...}: {
    options = {
      doas.enable = mkEnableOption {
        default = false;
        type = types.bool;
      };

      groups = mkOption {
        default = [];
        type = types.listOf string;
      };

      shell = mkOption {
        default = pkgs.bash;
        type = types.package;
      };

      hmPath = mkOption {
        type = types.path;
      };
    };
  });
in
{
  options.ltp.home = {
    users = mkOption {
      description = Attrset of home-manager users;
      default = {};
      type = types.attrsOf user;
    };
  };

  config = mkIf (cfg.users != {}) (mkMerge [
    {
      users.users = let mkUser =
        lib.attrsets.mapAttrs'
        (
          name: value:
          lib.attrsets.nameValuePair
            "${builtins.baseNameOf name}"
            {
              isNormalUser = true;
              extraGroups = "${groups}";
              shell = "${shell}";
            }
        )
        cfg.users;
      in
      mkUser;
      
      home-manager.users = let mkHmUser =
        lib.attrsets.mapAttrs'
        (
          name: value:
          lib.attrsets.nameValuePair
            "${builtins.baseNameOf name}"
            {
              imports = [ "${hmPath}" ];
            }
        )
        cfg.users;
      in
      mkHmUser;
    }
  ]);
}

Edit...

Solved the initial issue I was confusing myself and should've been using value.hmPath and equivalent inside the lib functions.

Next issue; I'm having is I can't seem to pass through the path for the home-manager module for the user that is give to the import statement.

Edit 2...

I didn't manage to get it working how I was doing it so I've changed my approach; to implicitly reference the users home-manager base module based on the folder structure e.g. ./hosts/${hostname}/users/${builtins.baseNameOf name}

25
 
 

Just a short elevator pitch that was posted today in that 100 seconds format. Maybe useful in introducing others.

view more: next ›