/ nix / nixosSystem.nix
nixosSystem.nix
 1  { nixpkgs
 2  , home-manager
 3  , system
 4  , specialArgs
 5  , nixos-modules
 6  ,
 7  }:
 8  let
 9    username = specialArgs.username;
10  in
11  nixpkgs.lib.nixosSystem {
12    inherit system specialArgs;
13    modules =
14      nixos-modules
15      // [
16        {
17          # make `nix run nixpkgs#nixpkgs` use the same nixpkgs as the one used by this flake.
18          nix.registry.nixpkgs.flake = nixpkgs;
19  
20          # make `nix repl '<nixpkgs>'` use the same nixpkgs as the one used by this flake.
21          environment.etc."nix/inputs/nixpkgs".source = "${nixpkgs}";
22          nix.nixPath = [ "/etc/nix/inputs" ];
23        }
24  
25        home-manager.nixosModules.home-manager
26        {
27          home-manager.useGlobalPkgs = true;
28          home-manager.useUserPackages = true;
29  
30          home-manager.extraSpecialArgs = specialArgs;
31        }
32      ];
33  }