summaryrefslogtreecommitdiff
path: root/flake.nix
diff options
context:
space:
mode:
authorGregor Kleen <gkleen@yggdrasil.li>2021-04-17 20:32:43 +0200
committerGregor Kleen <gkleen@yggdrasil.li>2021-04-17 20:32:43 +0200
commit38c553d0132ad48aa19d688a332be440536e51f2 (patch)
treef8bb8707acbb8ab4bad82e00e73a08e6af631f86 /flake.nix
parentedd926aa7e21caba277f46230d4262fae1631566 (diff)
parentdf02e465133be72aafbb083c16d80188cc8f1b13 (diff)
downloadnixos-38c553d0132ad48aa19d688a332be440536e51f2.tar
nixos-38c553d0132ad48aa19d688a332be440536e51f2.tar.gz
nixos-38c553d0132ad48aa19d688a332be440536e51f2.tar.bz2
nixos-38c553d0132ad48aa19d688a332be440536e51f2.tar.xz
nixos-38c553d0132ad48aa19d688a332be440536e51f2.zip
Merge branch 'flakes-template' into flakes
Diffstat (limited to 'flake.nix')
-rw-r--r--flake.nix21
1 files changed, 17 insertions, 4 deletions
diff --git a/flake.nix b/flake.nix
index 3c1507dd..e2567e84 100644
--- a/flake.nix
+++ b/flake.nix
@@ -41,7 +41,7 @@
41 accountName' = splitString "@" accountName; 41 accountName' = splitString "@" accountName;
42 in elemAt accountName' 1; 42 in elemAt accountName' 1;
43 43
44 mkNixosConfiguration = dir: path: hostName: nixosSystem rec { 44 mkNixosConfiguration = addProfiles: dir: path: hostName: nixosSystem rec {
45 specialArgs = { 45 specialArgs = {
46 flake = self; 46 flake = self;
47 flakeInputs = inputs; 47 flakeInputs = inputs;
@@ -60,7 +60,7 @@
60 }; 60 };
61 accountModules = attrValues (filterAttrs accountMatchesHost self.nixosModules.accounts); 61 accountModules = attrValues (filterAttrs accountMatchesHost self.nixosModules.accounts);
62 accountMatchesHost = n: _v: accountHostName n == hostName; 62 accountMatchesHost = n: _v: accountHostName n == hostName;
63 in attrValues (filterAttrs (n: _v: !(elem n ["systemProfiles" "users" "userProfiles" "accounts"])) self.nixosModules) ++ [ argsModule ] ++ defaultProfiles ++ [ local ] ++ accountModules; 63 in attrValues (filterAttrs (n: _v: !(elem n ["systemProfiles" "users" "userProfiles" "accounts"])) self.nixosModules) ++ [ argsModule ] ++ defaultProfiles ++ addProfiles ++ [ local ] ++ accountModules;
64 }; 64 };
65 65
66 mkSystemProfile = dir: path: profileName: { 66 mkSystemProfile = dir: path: profileName: {
@@ -110,6 +110,19 @@
110 activateNixosConfigurations = forAllSystems (system: _pkgs: mapAttrs' (hostName: nixosConfig: nameValuePair "${hostName}-activate" { type = "app"; program = "${nixosConfig.config.system.build.toplevel}/bin/switch-to-configuration"; }) self.nixosConfigurations); 110 activateNixosConfigurations = forAllSystems (system: _pkgs: mapAttrs' (hostName: nixosConfig: nameValuePair "${hostName}-activate" { type = "app"; program = "${nixosConfig.config.system.build.toplevel}/bin/switch-to-configuration"; }) self.nixosConfigurations);
111 111
112 overlayPaths = recImport rec { dir = ./overlays; _import = (path: _name: dir + "/${path}"); } // { pkgs = ./pkgs; }; 112 overlayPaths = recImport rec { dir = ./overlays; _import = (path: _name: dir + "/${path}"); } // { pkgs = ./pkgs; };
113
114 installerProfiles = system:
115 let nixpkgs-path = nixpkgs.legacyPackages.${system}.path;
116 in mapAttrs (name: {path, output}: { profile = mkSystemProfile nixpkgs-path path "installer-${name}"; inherit output; })
117 { cd-dvd = { path = "nixos/modules/installer/cd-dvd/installation-cd-minimal.nix"; output = out: out.config.system.build.isoImage; };
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 };
120
121 installers =
122 let mkInstallers = system: mapAttrs (mkInstaller system) (installerProfiles system);
123 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 !(builtins.isNull installerConfig) then { installers = forAllSystems (system: _systemPkgs: mkInstallers system); } else {};
113 in 126 in
114 { 127 {
115 nixosModules = 128 nixosModules =
@@ -120,7 +133,7 @@
120 accounts = recursiveUpdate rootAccounts (recImport rec { dir = ./accounts; _import = mkAccountModule dir; }); 133 accounts = recursiveUpdate rootAccounts (recImport rec { dir = ./accounts; _import = mkAccountModule dir; });
121 rootAccounts = mapAttrs' (hostName: _value: nameValuePair "root@${hostName}" ({...}: { imports = [ self.nixosModules.users.root or ({...}: { imports = defaultUserProfiles "root"; }) ]; })) self.nixosConfigurations; 134 rootAccounts = mapAttrs' (hostName: _value: nameValuePair "root@${hostName}" ({...}: { imports = [ self.nixosModules.users.root or ({...}: { imports = defaultUserProfiles "root"; }) ]; })) self.nixosConfigurations;
122 in modulesAttrs // { inherit systemProfiles users userProfiles accounts; }; 135 in modulesAttrs // { inherit systemProfiles users userProfiles accounts; };
123 nixosConfigurations = recImport rec { dir = ./hosts; _import = mkNixosConfiguration dir; }; 136 nixosConfigurations = recImport rec { dir = ./hosts; _import = mkNixosConfiguration [] dir; };
124 137
125 homeManagerModules = recImport rec { dir = ./home-modules; }; 138 homeManagerModules = recImport rec { dir = ./home-modules; };
126 139
@@ -142,5 +155,5 @@
142 path = ./.; 155 path = ./.;
143 description = "GKleen's flakey nixos configuration"; 156 description = "GKleen's flakey nixos configuration";
144 }; 157 };
145 }; 158 } // installers;
146} 159}