Nixos-rebuild error while using flakes

Hello all. I have been following this for guidance on my system configuration format.

Here is the error I get when trying to sudo nixos-rebuild build --flake .# --show-trace:

[nix-shell:/etc/nixos]# sudo nixos-rebuild build --flake . --show-trace
building the system configuration...
error:
       … while calling the 'seq' builtin

         at /nix/store/k5l01g2zwhysjyl5zjvg5zxnj0lyxpp1-source/lib/modules.nix:322:18:

          321|         options = checked options;
          322|         config = checked (removeAttrs config [ "_module" ]);
             |                  ^
          323|         _module = checked (config._module);

       … while evaluating a branch condition

         at /nix/store/k5l01g2zwhysjyl5zjvg5zxnj0lyxpp1-source/lib/modules.nix:261:9:

          260|       checkUnmatched =
          261|         if config._module.check && config._module.freeformType == null && merged.unmatchedDefns != [] then
             |         ^
          262|           let

       … in the right operand of the AND (&&) operator

         at /nix/store/k5l01g2zwhysjyl5zjvg5zxnj0lyxpp1-source/lib/modules.nix:261:72:

          260|       checkUnmatched =
          261|         if config._module.check && config._module.freeformType == null && merged.unmatchedDefns != [] then
             |                                                                        ^
          262|           let

       … while evaluating the attribute 'unmatchedDefns'

         at /nix/store/k5l01g2zwhysjyl5zjvg5zxnj0lyxpp1-source/lib/modules.nix:688:7:

          687|       # Transforms unmatchedDefnsByName into a list of definitions
          688|       unmatchedDefns =
             |       ^
          689|         if configs == []

       … while calling the 'concatLists' builtin

         at /nix/store/k5l01g2zwhysjyl5zjvg5zxnj0lyxpp1-source/lib/modules.nix:695:11:

          694|         else
          695|           concatLists (mapAttrsToList (name: defs:
             |           ^
          696|             map (def: def // {

       … while calling anonymous lambda

         at /nix/store/k5l01g2zwhysjyl5zjvg5zxnj0lyxpp1-source/lib/attrsets.nix:649:10:

          648|     attrs:
          649|     map (name: f name attrs.${name}) (attrNames attrs);
             |          ^
          650|

       … from call site

         at /nix/store/k5l01g2zwhysjyl5zjvg5zxnj0lyxpp1-source/lib/attrsets.nix:649:16:

          648|     attrs:
          649|     map (name: f name attrs.${name}) (attrNames attrs);
             |                ^
          650|

       … while calling anonymous lambda

         at /nix/store/k5l01g2zwhysjyl5zjvg5zxnj0lyxpp1-source/lib/modules.nix:695:46:

          694|         else
          695|           concatLists (mapAttrsToList (name: defs:
             |                                              ^
          696|             map (def: def // {

       … while calling anonymous lambda

         at /nix/store/k5l01g2zwhysjyl5zjvg5zxnj0lyxpp1-source/lib/modules.nix:681:22:

          680|         # Propagate all unmatched definitions from nested option sets
          681|         mapAttrs (n: v: v.unmatchedDefns) resultsByName
             |                      ^
          682|         # Plus the definitions for the current prefix that don't have a matching option

       … while calling anonymous lambda

         at /nix/store/k5l01g2zwhysjyl5zjvg5zxnj0lyxpp1-source/lib/attrsets.nix:649:10:

          648|     attrs:
          649|     map (name: f name attrs.${name}) (attrNames attrs);
             |          ^
          650|

       … from call site

         at /nix/store/k5l01g2zwhysjyl5zjvg5zxnj0lyxpp1-source/lib/attrsets.nix:649:16:

          648|     attrs:
          649|     map (name: f name attrs.${name}) (attrNames attrs);
             |                ^
          650|

       … while calling anonymous lambda

         at /nix/store/k5l01g2zwhysjyl5zjvg5zxnj0lyxpp1-source/lib/modules.nix:695:46:

          694|         else
          695|           concatLists (mapAttrsToList (name: defs:
             |                                              ^
          696|             map (def: def // {

       … while calling anonymous lambda

         at /nix/store/k5l01g2zwhysjyl5zjvg5zxnj0lyxpp1-source/lib/modules.nix:681:22:

          680|         # Propagate all unmatched definitions from nested option sets
          681|         mapAttrs (n: v: v.unmatchedDefns) resultsByName
             |                      ^
          682|         # Plus the definitions for the current prefix that don't have a matching option

       … while calling anonymous lambda

         at /nix/store/k5l01g2zwhysjyl5zjvg5zxnj0lyxpp1-source/lib/attrsets.nix:649:10:

          648|     attrs:
          649|     map (name: f name attrs.${name}) (attrNames attrs);
             |          ^
          650|

       … from call site

         at /nix/store/k5l01g2zwhysjyl5zjvg5zxnj0lyxpp1-source/lib/attrsets.nix:649:16:

          648|     attrs:
          649|     map (name: f name attrs.${name}) (attrNames attrs);
             |                ^
          650|

       … while calling anonymous lambda

         at /nix/store/k5l01g2zwhysjyl5zjvg5zxnj0lyxpp1-source/lib/modules.nix:695:46:

          694|         else
          695|           concatLists (mapAttrsToList (name: defs:
             |                                              ^
          696|             map (def: def // {

       … while calling anonymous lambda

         at /nix/store/k5l01g2zwhysjyl5zjvg5zxnj0lyxpp1-source/lib/modules.nix:681:22:

          680|         # Propagate all unmatched definitions from nested option sets
          681|         mapAttrs (n: v: v.unmatchedDefns) resultsByName
             |                      ^
          682|         # Plus the definitions for the current prefix that don't have a matching option

       … while calling anonymous lambda

         at /nix/store/k5l01g2zwhysjyl5zjvg5zxnj0lyxpp1-source/lib/attrsets.nix:649:10:

          648|     attrs:
          649|     map (name: f name attrs.${name}) (attrNames attrs);
             |          ^
          650|

       … from call site

         at /nix/store/k5l01g2zwhysjyl5zjvg5zxnj0lyxpp1-source/lib/attrsets.nix:649:16:

          648|     attrs:
          649|     map (name: f name attrs.${name}) (attrNames attrs);
             |                ^
          650|

       … while calling anonymous lambda

         at /nix/store/k5l01g2zwhysjyl5zjvg5zxnj0lyxpp1-source/lib/modules.nix:695:46:

          694|         else
          695|           concatLists (mapAttrsToList (name: defs:
             |                                              ^
          696|             map (def: def // {

       … while calling anonymous lambda

         at /nix/store/k5l01g2zwhysjyl5zjvg5zxnj0lyxpp1-source/lib/modules.nix:681:22:

          680|         # Propagate all unmatched definitions from nested option sets
          681|         mapAttrs (n: v: v.unmatchedDefns) resultsByName
             |                      ^
          682|         # Plus the definitions for the current prefix that don't have a matching option

       … from call site

         at /nix/store/k5l01g2zwhysjyl5zjvg5zxnj0lyxpp1-source/lib/modules.nix:695:24:

          694|         else
          695|           concatLists (mapAttrsToList (name: defs:
             |                        ^
          696|             map (def: def // {

       … while calling 'mapAttrsToList'

         at /nix/store/k5l01g2zwhysjyl5zjvg5zxnj0lyxpp1-source/lib/attrsets.nix:648:5:

          647|     # Attribute set to map over.
          648|     attrs:
             |     ^
          649|     map (name: f name attrs.${name}) (attrNames attrs);

       … while calling anonymous lambda

         at /nix/store/k5l01g2zwhysjyl5zjvg5zxnj0lyxpp1-source/lib/modules.nix:569:14:

          568|           lib.all
          569|             (c:
             |              ^
          570|               # TODO: I have my doubts that this error would occur when option definitions are not matched.

       error: value is a Boolean while a set was expected

I’ve double checked my paths, not sure what the issue is, especially as the error does not point to any one of my files. I’m using unstable nixpkgs, but it also does not build with stable nixpkgs as well.

Pretty sure I am having a fundamental misunderstanding of some kind and would appreciate some guidance.

Edit: backed up my /etc/nixos then went back to a simpler layout.

/etc/nixos:

├── configuration.nix
├── flake.lock
├── flake.nix
├── hardware-configuration.nix
├── home.nix
└── result -> /nix/store/06piahm8nilz043db44id4ykb37i2sgw-nixos-system-eye-24.05.20240309.3030f18

flake.nix
configuration.nix
home.nix

Can you post your config somewhere?

flake.nix
configuration.nix
home.nix

Looks like the culprit is hardware.nvidia.prime.offload:

    prime.offload = lib.mkForce false;

Indeed, nix flake check fails:

      … while checking the NixOS configuration 'nixosConfigurations.eye'

         at /nix/store/snrgrhl2nncf6fhjn4f11ng2ms4l036x-source/flake.nix:25:9:

           24|       nixosConfigurations = {
           25|         eye = nixpkgs.lib.nixosSystem {
             |         ^
           26|           system = "x86_64-linux";

       (stack trace truncated; use '--show-trace' to show the full trace)

       error: value is a Boolean while a set was expected

NixOS options search sez hardware.nvidia.prime.offload should be an attribute set, like so:

hardware.nvidia.prime.offload.enableOffloadCmd = lib.mkForce false;
hardware.nvidia.prime.offload.enable = lib.mkForce false;

For the record – no idea if you need or don’t need prime offload, this comment is only about the syntax :slight_smile:

I think Nix 2.20 will make the error reporting much better in this case.

Yep, that was it. Guess that’s why you don’t redo your config at 4am ahaha- stupid mistake. The error reporting made this so much harder than it needed to be, really looking forward to nix 2.20!

Appreciate the second set of eyes on this, thank you.