summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--flake.nix27
-rw-r--r--pkgs/default.nix3
2 files changed, 17 insertions, 13 deletions
diff --git a/flake.nix b/flake.nix
index eb6f1fda..021146ea 100644
--- a/flake.nix
+++ b/flake.nix
@@ -30,7 +30,7 @@
30 inherit (nixpkgs) lib; 30 inherit (nixpkgs) lib;
31 utils = import ./utils { inherit lib; }; 31 utils = import ./utils { inherit lib; };
32 inherit (utils) nixImport overrideModule; 32 inherit (utils) nixImport overrideModule;
33 inherit (lib) nixosSystem mkIf splitString filterAttrs listToAttrs mapAttrsToList nameValuePair concatMap composeManyExtensions mapAttrs mapAttrs' recursiveUpdate genAttrs unique elem optionalAttrs; 33 inherit (lib) nixosSystem mkIf splitString filterAttrs listToAttrs mapAttrsToList nameValuePair concatMap composeManyExtensions mapAttrs mapAttrs' recursiveUpdate genAttrs unique elem optionalAttrs isDerivation concatLists;
34 34
35 accountUserName = accountName: 35 accountUserName = accountName:
36 let 36 let
@@ -104,12 +104,13 @@
104 // outputs 104 // outputs
105 // { imports = [self.nixosModules.users.${userName} or ({...}: { imports = defaultUserProfiles userName; })] ++ (outputs.imports or []); }); 105 // { imports = [self.nixosModules.users.${userName} or ({...}: { imports = defaultUserProfiles userName; })] ++ (outputs.imports or []); });
106 106
107 forAllSystems = f: mapAttrs f nixpkgs.legacyPackages; 107 systemsSelector = "(x86_64|i686)-linux";
108 forAllSystems = f: mapAttrs f (filterAttrs (system: _systemPkgs: !(isNull (builtins.match systemsSelector system))) nixpkgs.legacyPackages);
108 forAllUsers = genAttrs (unique (map accountUserName (attrNames self.nixosModules.accounts))); 109 forAllUsers = genAttrs (unique (map accountUserName (attrNames self.nixosModules.accounts)));
109 110
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 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 112
112 overlayPaths = nixImport rec { dir = ./overlays; _import = (path: _name: dir + "/${path}"); } // { pkgs = ./pkgs; }; 113 overlayPaths = nixImport rec { dir = ./overlays; _import = (path: _name: dir + "/${path}"); };
113 114
114 installerProfiles = system: 115 installerProfiles = system:
115 let nixpkgs-path = nixpkgs.legacyPackages.${system}.path; 116 let nixpkgs-path = nixpkgs.legacyPackages.${system}.path;
@@ -121,8 +122,13 @@
121 installerConfig = if pathExists ./installer.nix then "installer.nix" else (if pathExists ./installer then "installer" else null); 122 installerConfig = if pathExists ./installer.nix then "installer.nix" else (if pathExists ./installer then "installer" else null);
122 installers = 123 installers =
123 let mkInstallers = system: mapAttrs (mkInstaller system) (installerProfiles system); 124 let mkInstallers = system: mapAttrs (mkInstaller system) (installerProfiles system);
124 mkInstaller = system: name: {profile, output}: output (mkNixosConfiguration [profile { config = { nixpkgs.system = system; }; }] ./. installerConfig "installer"); 125 mkInstaller = system: name: {profile, output}: let mkOutput = output; in rec { config = mkNixosConfiguration [profile { config = { nixpkgs.system = system; }; }] ./. installerConfig "installer"; output = mkOutput config; };
125 in if !(isNull installerConfig) then { installers = forAllSystems (system: _systemPkgs: mkInstallers system); } else {}; 126 in forAllSystems (system: _systemPkgs: optionalAttrs (!(isNull installerConfig)) (mkInstallers system));
127 installerNixosConfigurations = listToAttrs (concatLists (mapAttrsToList (system: mapAttrsToList (profile: { config, ... }: nameValuePair ("installer-${system}-${profile}") config)) installers));
128
129 packages =
130 let installerPackages = system: optionalAttrs (!(isNull installerConfig)) (mapAttrs' (profile: value: nameValuePair "installer-${profile}" value.output) installers.${system});
131 in forAllSystems (system: systemPkgs: self.overlay (self.legacyPackages.${system}) systemPkgs // installerPackages system);
126 in 132 in
127 { 133 {
128 nixosModules = 134 nixosModules =
@@ -133,19 +139,20 @@
133 accounts = recursiveUpdate rootAccounts (nixImport rec { dir = ./accounts; _import = mkAccountModule dir; }); 139 accounts = recursiveUpdate rootAccounts (nixImport rec { dir = ./accounts; _import = mkAccountModule dir; });
134 rootAccounts = mapAttrs' (hostName: _value: nameValuePair "root@${hostName}" ({...}: { imports = [ self.nixosModules.users.root or ({...}: { imports = defaultUserProfiles "root"; }) ]; })) self.nixosConfigurations; 140 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; }; 141 in modulesAttrs // { inherit systemProfiles users userProfiles accounts; };
136 nixosConfigurations = optionalAttrs (!(isNull installerConfig)) { installer = installerConfig; } // nixImport rec { dir = ./hosts; _import = mkNixosConfiguration [] dir; }; 142 nixosConfigurations = installerNixosConfigurations // nixImport rec { dir = ./hosts; _import = mkNixosConfiguration [] dir; };
137 143
138 homeManagerModules = nixImport rec { dir = ./home-modules; }; 144 homeManagerModules = nixImport rec { dir = ./home-modules; };
139 145
140 overlay = import overlayPaths.pkgs; 146 overlay = final: prev: composeManyExtensions (attrValues self.overlays) final prev;
141 overlays = mapAttrs (_name: path: import path) overlayPaths; 147 overlays = mapAttrs (_name: path: import path) overlayPaths;
142 overlays-path = forAllSystems (system: _: self.legacyPackages.${system}.writeText "overlays.nix" '' 148 overlays-path = forAllSystems (system: _: self.legacyPackages.${system}.writeText "overlays.nix" ''
143 map import (builtins.attrValues (builtins.fromJSON (builtins.readFile ${self.legacyPackages.${system}.writeText "overlays.json" (toJSON overlayPaths)}))) 149 map import (builtins.attrValues (builtins.fromJSON (builtins.readFile ${self.legacyPackages.${system}.writeText "overlays.json" (toJSON overlayPaths)})))
144 ''); 150 '');
145 151
146 packages = forAllSystems (system: systemPkgs: composeManyExtensions (attrValues self.overlays) (self.legacyPackages.${system}) systemPkgs); 152 packages = mapAttrs (_name: filterAttrs (_name: isDerivation)) packages;
153 packages' = mapAttrs (_name: filterAttrs (_name: value: !(isDerivation value))) packages;
147 154
148 legacyPackages = forAllSystems (system: systemPkgs: recursiveUpdate systemPkgs self.packages.${system}); 155 legacyPackages = forAllSystems (system: systemPkgs: recursiveUpdate systemPkgs packages.${system});
149 156
150 apps = activateNixosConfigurations; 157 apps = activateNixosConfigurations;
151 158
@@ -155,5 +162,5 @@
155 path = ./.; 162 path = ./.;
156 description = "GKleen's flakey nixos configuration"; 163 description = "GKleen's flakey nixos configuration";
157 }; 164 };
158 } // installers; 165 };
159} 166}
diff --git a/pkgs/default.nix b/pkgs/default.nix
deleted file mode 100644
index b5d83487..00000000
--- a/pkgs/default.nix
+++ /dev/null
@@ -1,3 +0,0 @@
1self: super:
2{
3}