Nixos not being able to rebuild with flake because of an unexpected LET

I am having trouble getting started with flakes. I have initD in the /mysystem and /mysystem/. I get the error below it seems something might have changed in the past year.

the command I run is 

sudo nixos-rebuild switch --flake ~/mysystem/<user>

error

error: syntax error, unexpected LET, expecting INHERIT
       at /nix/store/p24672jvf7qiagvq32599c1ggni9y1hn-source/flake.nix:9:3:
            8|   outputs = { self, nixpkgs }: {
            9|   let
             |   ^
           10|     system = "x86_64-linux";
Command 'nix --extra-experimental-features 'nix-command flakes' build --print-out-paths '/home/<username>/mysystem/nimo#nixosConfigurations."<hostname>".config.system.build.nixos-rebuild' --no-link' returned non-zero exit status 1.


flake.nix

{
  description = "A very basic flake";

  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-25.11";
  };

  outputs = { self, nixpkgs }: {
  let
    system = "x86_64-linux";

    pkgs = import nixpkgs {
    
      inherit systen;

      config = {
       allowUnfree = true;
      };
  
    };

  in
  {
   # packages.x86_64-linux.hello = nixpkgs.legacyPackages.x86_64-linux.hello;

    #packages.x86_64-linux.default = self.packages.x86_64-linux.hello;
   
    nixosConfiguration = {
     myNixos = nixpkgs.lib.nixosSystem {
      specialArgs = {inherit system;};
      module = [
       ./nixos/configuration.nix
      ];
     };
    };
    #packages.x86_64-linux.nixosConfigurations."<hostname>".config.system.build.nixos-rebuild = nixpkgs.legacyPackages.x86_64-linux.nixosConfigurations."<hostname>".config.system.build.nixos-rebuild;
  };
}

I am on my smartphone, thus i can not use a linter for final checking, tho the { before the let on the line above looks wrong to me.

4 Likes

I think the syntax is incorrect. remove the { before let

outputs = { self, nixpkgs }: {
#                           ^^^

Correct:

outputs = { self, nixpkgs }: 
1 Like

Agree with both of the above. A let in lock sits between expressions and not inside of them.

1 Like

That was the one of the issues!

Thank you :slight_smile:

1 Like

Got it working it was a bunch of syntax errors for sure. I need to set up linter. which one do you recommend?