diff options
author | Gregor Kleen <gkleen@yggdrasil.li> | 2021-05-15 16:40:27 +0200 |
---|---|---|
committer | Gregor Kleen <gkleen@yggdrasil.li> | 2021-05-15 16:40:27 +0200 |
commit | fc6123bf8577ca76b0c1458aa0ae6aedce62c5e3 (patch) | |
tree | 1fff89002982afe156ba60aa57c9f8753651fb83 /flake.nix | |
parent | 9c6daafda74e18ff33f97d90f5ae958d693f85e0 (diff) | |
download | nixos-fc6123bf8577ca76b0c1458aa0ae6aedce62c5e3.tar nixos-fc6123bf8577ca76b0c1458aa0ae6aedce62c5e3.tar.gz nixos-fc6123bf8577ca76b0c1458aa0ae6aedce62c5e3.tar.bz2 nixos-fc6123bf8577ca76b0c1458aa0ae6aedce62c5e3.tar.xz nixos-fc6123bf8577ca76b0c1458aa0ae6aedce62c5e3.zip |
...
Diffstat (limited to 'flake.nix')
-rw-r--r-- | flake.nix | 12 |
1 files changed, 6 insertions, 6 deletions
@@ -26,11 +26,11 @@ | |||
26 | 26 | ||
27 | outputs = { self, nixpkgs, home-manager, sops-nix }@inputs: | 27 | outputs = { self, nixpkgs, home-manager, sops-nix }@inputs: |
28 | let | 28 | let |
29 | inherit (builtins) attrNames attrValues elemAt toJSON; | 29 | inherit (builtins) attrNames attrValues elemAt toJSON isNull pathExists; |
30 | inherit (nixpkgs) lib; | 30 | inherit (nixpkgs) lib; |
31 | utils = import ./utils { inherit lib; }; | 31 | utils = import ./utils { inherit lib; }; |
32 | inherit (utils) recImport overrideModule; | 32 | inherit (utils) recImport overrideModule; |
33 | inherit (lib) nixosSystem mkIf splitString filterAttrs listToAttrs mapAttrsToList nameValuePair concatMap composeManyExtensions mapAttrs mapAttrs' recursiveUpdate genAttrs unique elem; | 33 | inherit (lib) nixosSystem mkIf splitString filterAttrs listToAttrs mapAttrsToList nameValuePair concatMap composeManyExtensions mapAttrs mapAttrs' recursiveUpdate genAttrs unique elem optionalAttrs; |
34 | 34 | ||
35 | accountUserName = accountName: | 35 | accountUserName = accountName: |
36 | let | 36 | let |
@@ -118,11 +118,11 @@ | |||
118 | netboot = { path = "nixos/modules/installer/netboot/netboot-minimal.nix"; output = out: (self.legacyPackages.${system}.symlinkJoin { name = "netboot"; paths = with out.config.system.build; [ netbootRamdisk kernel netbootIpxeScript ]; preferLocalBuild = true; }); }; | 118 | netboot = { path = "nixos/modules/installer/netboot/netboot-minimal.nix"; output = out: (self.legacyPackages.${system}.symlinkJoin { name = "netboot"; paths = with out.config.system.build; [ netbootRamdisk kernel netbootIpxeScript ]; preferLocalBuild = true; }); }; |
119 | }; | 119 | }; |
120 | 120 | ||
121 | installerConfig = if pathExists ./installer.nix then "installer.nix" else (if pathExists ./installer then "installer" else null); | ||
121 | installers = | 122 | installers = |
122 | let mkInstallers = system: mapAttrs (mkInstaller system) (installerProfiles system); | 123 | let mkInstallers = system: mapAttrs (mkInstaller system) (installerProfiles system); |
123 | mkInstaller = system: name: {profile, output}: output (mkNixosConfiguration [profile { config = { nixpkgs.system = system; }; }] ./. installerConfig "installer"); | 124 | mkInstaller = system: name: {profile, output}: output (mkNixosConfiguration [profile { config = { nixpkgs.system = system; }; }] ./. installerConfig "installer"); |
124 | installerConfig = if builtins.pathExists ./installer.nix then "installer.nix" else (if builtins.pathExists ./installer then "installer" else null); | 125 | in if !(isNull installerConfig) then { installers = forAllSystems (system: _systemPkgs: mkInstallers system); } else {}; |
125 | in if !(builtins.isNull installerConfig) then { installers = forAllSystems (system: _systemPkgs: mkInstallers system); } else {}; | ||
126 | in | 126 | in |
127 | { | 127 | { |
128 | nixosModules = | 128 | nixosModules = |
@@ -131,9 +131,9 @@ | |||
131 | users = recImport rec { dir = ./users; _import = mkUserModule dir; }; | 131 | users = recImport rec { dir = ./users; _import = mkUserModule dir; }; |
132 | userProfiles = forAllUsers (userName: recImport rec { dir = ./user-profiles; _import = mkUserProfile userName dir; }); | 132 | userProfiles = forAllUsers (userName: recImport rec { dir = ./user-profiles; _import = mkUserProfile userName dir; }); |
133 | accounts = recursiveUpdate rootAccounts (recImport rec { dir = ./accounts; _import = mkAccountModule dir; }); | 133 | accounts = recursiveUpdate rootAccounts (recImport rec { dir = ./accounts; _import = mkAccountModule dir; }); |
134 | rootAccounts = listToAttrs (map (hostName: nameValuePair "root@${hostName}" ({...}: { imports = [ self.nixosModules.users.root or ({...}: { imports = defaultUserProfiles "root"; }) ]; })) (attrNames self.nixosConfigurations ++ lib.optional (installers != {}) "installer" )); | 134 | rootAccounts = mapAttrs' (hostName: _value: nameValuePair "root@${hostName}" ({...}: { imports = [ self.nixosModules.users.root or ({...}: { imports = defaultUserProfiles "root"; }) ]; })) self.nixosConfigurations; |
135 | in modulesAttrs // { inherit systemProfiles users userProfiles accounts; }; | 135 | in modulesAttrs // { inherit systemProfiles users userProfiles accounts; }; |
136 | nixosConfigurations = recImport rec { dir = ./hosts; _import = mkNixosConfiguration [] dir; }; | 136 | nixosConfigurations = optionalAttrs (!(isNull installerConfig)) { installer = installerConfig; } // recImport rec { dir = ./hosts; _import = mkNixosConfiguration [] dir; }; |
137 | 137 | ||
138 | homeManagerModules = recImport rec { dir = ./home-modules; }; | 138 | homeManagerModules = recImport rec { dir = ./home-modules; }; |
139 | 139 | ||