diff options
Diffstat (limited to 'flake.nix')
-rw-r--r-- | flake.nix | 60 |
1 files changed, 51 insertions, 9 deletions
@@ -4,9 +4,11 @@ | |||
4 | nixConfig = { | 4 | nixConfig = { |
5 | extra-substituters = [ | 5 | extra-substituters = [ |
6 | "https://nix-community.cachix.org" | 6 | "https://nix-community.cachix.org" |
7 | "https://niri.cachix.org" | ||
7 | ]; | 8 | ]; |
8 | extra-trusted-public-keys = [ | 9 | extra-trusted-public-keys = [ |
9 | "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=" | 10 | "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=" |
11 | "niri.cachix.org-1:Wv0OmO7PsuocRKzfDoJ3mulSl7Z6oezYhGhR+3W2964=" | ||
10 | ]; | 12 | ]; |
11 | }; | 13 | }; |
12 | 14 | ||
@@ -123,6 +125,21 @@ | |||
123 | nixpkgs.follows = "nixpkgs"; | 125 | nixpkgs.follows = "nixpkgs"; |
124 | }; | 126 | }; |
125 | }; | 127 | }; |
128 | pyproject-nix = { | ||
129 | url = "github:pyproject-nix/pyproject.nix"; | ||
130 | inputs.nixpkgs.follows = "nixpkgs"; | ||
131 | }; | ||
132 | uv2nix = { | ||
133 | url = "github:pyproject-nix/uv2nix"; | ||
134 | inputs.pyproject-nix.follows = "pyproject-nix"; | ||
135 | inputs.nixpkgs.follows = "nixpkgs"; | ||
136 | }; | ||
137 | pyproject-build-systems = { | ||
138 | url = "github:pyproject-nix/build-system-pkgs"; | ||
139 | inputs.pyproject-nix.follows = "pyproject-nix"; | ||
140 | inputs.uv2nix.follows = "uv2nix"; | ||
141 | inputs.nixpkgs.follows = "nixpkgs"; | ||
142 | }; | ||
126 | 143 | ||
127 | ca-util = { | 144 | ca-util = { |
128 | type = "gitlab"; | 145 | type = "gitlab"; |
@@ -170,7 +187,7 @@ | |||
170 | type = "github"; | 187 | type = "github"; |
171 | owner = "gkleen"; | 188 | owner = "gkleen"; |
172 | repo = "Waybar"; | 189 | repo = "Waybar"; |
173 | ref = "feat/privacy-ignore"; | 190 | ref = "feat/niri-urgency"; |
174 | inputs = { | 191 | inputs = { |
175 | nixpkgs.follows = "nixpkgs"; | 192 | nixpkgs.follows = "nixpkgs"; |
176 | flake-compat.follows = "flake-compat"; | 193 | flake-compat.follows = "flake-compat"; |
@@ -182,9 +199,28 @@ | |||
182 | repo = "NixVirt"; | 199 | repo = "NixVirt"; |
183 | inputs.nixpkgs.follows = "nixpkgs"; | 200 | inputs.nixpkgs.follows = "nixpkgs"; |
184 | }; | 201 | }; |
202 | niri-flake = { | ||
203 | type = "github"; | ||
204 | owner = "sodiboo"; | ||
205 | repo = "niri-flake"; | ||
206 | ref = "main"; | ||
207 | inputs = { | ||
208 | nixpkgs.follows = "nixpkgs"; | ||
209 | # niri-unstable.url = "github:gkleen/niri"; | ||
210 | }; | ||
211 | }; | ||
212 | nix-monitored = { | ||
213 | type = "github"; | ||
214 | owner = "ners"; | ||
215 | repo = "nix-monitored"; | ||
216 | ref = "master"; | ||
217 | inputs = { | ||
218 | nixpkgs.follows = "nixpkgs"; | ||
219 | }; | ||
220 | }; | ||
185 | }; | 221 | }; |
186 | 222 | ||
187 | outputs = { self, nixpkgs, home-manager, sops-nix, deploy-rs, nvfetcher, ... }@inputs: | 223 | outputs = { self, nixpkgs, home-manager, sops-nix, deploy-rs, nvfetcher, niri-flake, ... }@inputs: |
188 | let | 224 | let |
189 | inherit (builtins) attrNames attrValues elemAt toJSON isNull pathExists; | 225 | inherit (builtins) attrNames attrValues elemAt toJSON isNull pathExists; |
190 | inherit (nixpkgs) lib; | 226 | inherit (nixpkgs) lib; |
@@ -267,9 +303,10 @@ | |||
267 | mkAccountModule = dir: path: accountName: | 303 | mkAccountModule = dir: path: accountName: |
268 | let | 304 | let |
269 | userName = accountUserName accountName; | 305 | userName = accountUserName accountName; |
306 | hostName = accountHostName accountName; | ||
270 | in overrideModule | 307 | in overrideModule |
271 | (import (dir + "/${path}")) | 308 | (import (dir + "/${path}")) |
272 | (inputs: inputs // { inherit userName; }) | 309 | (inputs: inputs // { inherit userName hostName; }) |
273 | (outputs: { _file = dir + "/${path}"; } | 310 | (outputs: { _file = dir + "/${path}"; } |
274 | // outputs | 311 | // outputs |
275 | // { imports = [self.nixosModules.users.${userName} or ({...}: { imports = defaultUserProfiles userName; })] ++ (outputs.imports or []); }); | 312 | // { imports = [self.nixosModules.users.${userName} or ({...}: { imports = defaultUserProfiles userName; })] ++ (outputs.imports or []); }); |
@@ -285,7 +322,7 @@ | |||
285 | forAllUsers = genAttrs (unique (map accountUserName (attrNames self.nixosModules.accounts))); | 322 | forAllUsers = genAttrs (unique (map accountUserName (attrNames self.nixosModules.accounts))); |
286 | 323 | ||
287 | activateNixosConfigurations = forAllSystems (system: _pkgs: filterAttrs (_n: v: v != null) (mapAttrs' (hostName: nixosConfig: nameValuePair "${hostName}-activate" (if system == nixosConfig.config.nixpkgs.system then { type = "app"; program = "${nixosConfig.config.system.build.toplevel}/bin/switch-to-configuration"; } else null)) self.nixosConfigurations)); | 324 | activateNixosConfigurations = forAllSystems (system: _pkgs: filterAttrs (_n: v: v != null) (mapAttrs' (hostName: nixosConfig: nameValuePair "${hostName}-activate" (if system == nixosConfig.config.nixpkgs.system then { type = "app"; program = "${nixosConfig.config.system.build.toplevel}/bin/switch-to-configuration"; } else null)) self.nixosConfigurations)); |
288 | startVMs = forAllSystems (system: pkgs: mapAttrs' (hostName: nixosConfig: nameValuePair "run-${hostName}-vm" { type = "app"; program = "${nixosConfig.config.system.build.vm}/bin/run-${hostName}-vm"; }) (nixImport rec { dir = ./hosts; _import = mkNixosConfiguration [ { config.virtualisation.host.pkgs = pkgs; } ] dir; })); | 325 | # startVMs = forAllSystems (system: pkgs: mapAttrs' (hostName: nixosConfig: nameValuePair "run-${hostName}-vm" { type = "app"; program = "${nixosConfig.config.system.build.vm}/bin/run-${hostName}-vm"; }) (nixImport rec { dir = ./hosts; _import = mkNixosConfiguration [ { config.virtualisation.host.pkgs = pkgs; } ] dir; })); |
289 | activateHomeManagerConfigurations = forAllSystems (system: _pkgs: filterAttrs (_n: v: v != null) (listToAttrs (concatLists (mapAttrsToList (hostName: nixosConfig: mapAttrsToList (userName: userCfg: nameValuePair "${userName}@${hostName}-activate" (if system == nixosConfig.config.nixpkgs.system then { type = "app"; program = "${userCfg.home.activationPackage}/activate"; } else null)) nixosConfig.config.home-manager.users) self.nixosConfigurations)))); | 326 | activateHomeManagerConfigurations = forAllSystems (system: _pkgs: filterAttrs (_n: v: v != null) (listToAttrs (concatLists (mapAttrsToList (hostName: nixosConfig: mapAttrsToList (userName: userCfg: nameValuePair "${userName}@${hostName}-activate" (if system == nixosConfig.config.nixpkgs.system then { type = "app"; program = "${userCfg.home.activationPackage}/activate"; } else null)) nixosConfig.config.home-manager.users) self.nixosConfigurations)))); |
290 | installerShells = system: pkgs: mapAttrs (installerName: config: pkgs.callPackage ./installer/shell.nix { | 327 | installerShells = system: pkgs: mapAttrs (installerName: config: pkgs.callPackage ./installer/shell.nix { |
291 | inherit system installerName config; | 328 | inherit system installerName config; |
@@ -322,18 +359,23 @@ | |||
322 | nixosConfigurations = installerNixosConfigurations // nixImport rec { dir = ./hosts; _import = mkNixosConfiguration [] dir; }; | 359 | nixosConfigurations = installerNixosConfigurations // nixImport rec { dir = ./hosts; _import = mkNixosConfiguration [] dir; }; |
323 | 360 | ||
324 | homeModules = nixImport rec { dir = ./home-modules; }; | 361 | homeModules = nixImport rec { dir = ./home-modules; }; |
325 | homeConfigurations = listToAttrs (concatLists (mapAttrsToList (hostname: nixosConfig: mapAttrsToList (username: configuration: nameValuePair "${username}@${hostname}" { inherit (configuration.home) activationPackage; }) nixosConfig.config.home-manager.users) self.nixosConfigurations)); | 362 | homeConfigurations = listToAttrs (concatLists (mapAttrsToList (hostname: nixosConfig: mapAttrsToList (username: nameValuePair "${username}@${hostname}") nixosConfig.config.home-manager.users) self.nixosConfigurations)); |
326 | 363 | ||
327 | overlays = mapAttrs (_name: path: mkOverlay path) overlayPaths; | 364 | overlays = mapAttrs (_name: path: mkOverlay path) overlayPaths; |
328 | 365 | ||
329 | packages = forAllSystems (system: systemPkgs: nixImport rec { dir = ./tools; _import = _path: name: import "${toString dir}/${name}" ({ inherit system; } // inputs); }); | 366 | packages = forAllSystems (system: systemPkgs: nixImport rec { dir = ./tools; _import = name: _base: import (dir + "/${name}") ({ inherit system; } // inputs); }); |
330 | 367 | ||
331 | # packages = mapAttrs (_name: filterAttrs (_name: isDerivation)) packages; | 368 | # packages = mapAttrs (_name: filterAttrs (_name: isDerivation)) packages; |
332 | # packages' = mapAttrs (_name: filterAttrs (_name: value: !(isDerivation value))) packages; | 369 | # packages' = mapAttrs (_name: filterAttrs (_name: value: !(isDerivation value))) packages; |
333 | 370 | ||
334 | legacyPackages = forAllSystems (system: systemPkgs: systemPkgs.override { overlays = attrValues self.overlays; }); | 371 | legacyPackages = forAllSystems (system: systemPkgs: systemPkgs.override { overlays = attrValues self.overlays; }); |
335 | 372 | ||
336 | apps = foldr recursiveUpdate {} [startVMs activateNixosConfigurations activateHomeManagerConfigurations]; | 373 | apps = foldr recursiveUpdate {} [ |
374 | #startVMs | ||
375 | activateNixosConfigurations activateHomeManagerConfigurations | ||
376 | ]; | ||
377 | |||
378 | lib = nixImport rec { dir = ./lib; _import = name: _base: import (dir + "/${name}") inputs; }; | ||
337 | 379 | ||
338 | devShells = forAllSystems (system: systemPkgs: { default = import ./shell.nix ({ inherit system; } // inputs); } // installerShells system systemPkgs); | 380 | devShells = forAllSystems (system: systemPkgs: { default = import ./shell.nix ({ inherit system; } // inputs); } // installerShells system systemPkgs); |
339 | 381 | ||
@@ -358,10 +400,10 @@ | |||
358 | # path = activateHomeManager (self.nixosConfigurations.${hostname}.config.nixpkgs.system) usercfg.home; | 400 | # path = activateHomeManager (self.nixosConfigurations.${hostname}.config.nixpkgs.system) usercfg.home; |
359 | # }) self.nixosConfigurations.${hostname}.config.home-manager.users); | 401 | # }) self.nixosConfigurations.${hostname}.config.home-manager.users); |
360 | }) (nixImport { dir = ./hosts; _import = (_path: name: name); }); | 402 | }) (nixImport { dir = ./hosts; _import = (_path: name: name); }); |
361 | overrides = if pathExists ./deploy then nixImport { dir = ./deploy; _import = path: _name: import (./deploy + "/${path}") inputs; } else {}; | 403 | overrides = if pathExists ./deploy then nixImport rec { dir = ./deploy; _import = path: _name: import (dir + "/${path}") inputs; } else {}; |
362 | filterEnabled = attrs: mapAttrs (_n: v: filterAttrs (n: _v: n != "enabled") v) (filterAttrs (_n: v: v.enabled or true) attrs); | 404 | filterEnabled = attrs: mapAttrs (_n: v: filterAttrs (n: _v: n != "enabled") v) (filterAttrs (_n: v: v.enabled or true) attrs); |
363 | in mapAttrs (_n: v: if v ? "profiles" then v // { profiles = filterEnabled v.profiles; } else v) (filterEnabled (recursiveUpdate defaults overrides)); | 405 | in mapAttrs (_n: v: if v ? "profiles" then v // { profiles = filterEnabled v.profiles; } else v) (filterEnabled (recursiveUpdate defaults overrides)); |
364 | 406 | ||
365 | checks = builtins.mapAttrs (system: deployLib: deployLib.deployChecks self.deploy) deploy-rs.lib; | 407 | # checks = builtins.mapAttrs (system: deployLib: deployLib.deployChecks self.deploy) deploy-rs.lib; |
366 | }; | 408 | }; |
367 | } | 409 | } |