Sudo nixos-rebuild switch error

can anyone help pls

❯ sudo nixos-rebuild switch
[sudo] password for libre:
warning: $HOME (‘/home/libre’) is not owned by you, falling back to the one defined in the ‘passwd’ file (‘/root’)
error:
… while calling the ‘seq’ builtin
at «github:NixOS/nixpkgs/801bef6abd86b91e51083066b83fb354a11fc640?narHash=sha256-hLD4l3QOGBQhkVp3mQ2lJ/YbEi99qUgKapb40KovZ88%3D»/lib/modules.nix:401:18:
400| options = checked options;
401| config = checked (removeAttrs config [ “_module” ]);
| ^
402| _module = checked (config._module);

   … while evaluating a branch condition
     at «github:NixOS/nixpkgs/801bef6abd86b91e51083066b83fb354a11fc640?narHash=sha256-hLD4l3QOGBQhkVp3mQ2lJ/YbEi99qUgKapb40KovZ88%3D»/lib/modules.nix:304:9:
      303|       checkUnmatched =
      304|         if config._module.check && config._module.freeformType == null && merged.unmatchedDefns != [ ] then
         |         ^
      305|           let

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

   error: syntax error, unexpected ',', expecting '.' or '='
   at /nix/store/1c77mf0yy0460n25c1irwz1fyvj0lvgi-source/configuration.nix:5:9:
        4|
        5| { config, pkgs, ... }:
         |         ^
        6|Command ‘nix --extra-experimental-features ‘nix-command flakes’ build --print-out-paths ‘/etc/nixos#nixosConfigurations.“nixos”.config.system.build.nixos-rebuild’ --no-link’ returned non-zero exit status 1.

You’d need to share your actual config. You seem to have a syntax error, but it’s hard to know what’s the issue exactly without seeing more context.

1 Like

This looks quite incorrect to me, that line

{ config, pkgs, ... }:

Should be the first line of a module, so seeing it on the 5th line makes me assume you doubled up something and have a basic syntax error.
See:

Modules are a function that return an attrset, or just a plain attrset; ensure to conform to the syntax discussed above.

1 Like