diff options
Diffstat (limited to 'flake.nix')
| -rw-r--r-- | flake.nix | 148 |
1 files changed, 102 insertions, 46 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 | ||
| @@ -27,35 +29,17 @@ | |||
| 27 | type = "github"; | 29 | type = "github"; |
| 28 | owner = "NixOS"; | 30 | owner = "NixOS"; |
| 29 | repo = "nixpkgs"; | 31 | repo = "nixpkgs"; |
| 30 | ref = "24.05"; | 32 | ref = "25.05"; |
| 31 | }; | ||
| 32 | nixpkgs-eostre = { | ||
| 33 | type = "github"; | ||
| 34 | owner = "NixOS"; | ||
| 35 | repo = "nixpkgs"; | ||
| 36 | ref = "23.11"; | ||
| 37 | }; | 33 | }; |
| 38 | home-manager = { | 34 | home-manager = { |
| 39 | type = "github"; | 35 | type = "github"; |
| 40 | # owner = "nix-community"; | 36 | owner = "nix-community"; |
| 41 | # repo = "home-manager"; | ||
| 42 | # ref = "master"; | ||
| 43 | owner = "gkleen"; | ||
| 44 | repo = "home-manager"; | 37 | repo = "home-manager"; |
| 45 | ref = "nixos-late-start"; | 38 | ref = "master"; |
| 46 | inputs = { | 39 | inputs = { |
| 47 | nixpkgs.follows = "nixpkgs"; | 40 | nixpkgs.follows = "nixpkgs"; |
| 48 | }; | 41 | }; |
| 49 | }; | 42 | }; |
| 50 | home-manager-eostre = { | ||
| 51 | type = "github"; | ||
| 52 | owner = "gkleen"; | ||
| 53 | repo = "home-manager"; | ||
| 54 | ref = "nixos-late-start-23.11"; | ||
| 55 | inputs = { | ||
| 56 | nixpkgs.follows = "nixpkgs-eostre"; | ||
| 57 | }; | ||
| 58 | }; | ||
| 59 | sops-nix = { | 43 | sops-nix = { |
| 60 | type = "github"; | 44 | type = "github"; |
| 61 | owner = "Mic92"; | 45 | owner = "Mic92"; |
| @@ -106,7 +90,7 @@ | |||
| 106 | }; | 90 | }; |
| 107 | nix-index-database = { | 91 | nix-index-database = { |
| 108 | type = "github"; | 92 | type = "github"; |
| 109 | owner = "Mic92"; | 93 | owner = "nix-community"; |
| 110 | repo = "nix-index-database"; | 94 | repo = "nix-index-database"; |
| 111 | ref = "main"; | 95 | ref = "main"; |
| 112 | inputs = { | 96 | inputs = { |
| @@ -123,35 +107,62 @@ | |||
| 123 | nixpkgs.follows = "nixpkgs"; | 107 | nixpkgs.follows = "nixpkgs"; |
| 124 | }; | 108 | }; |
| 125 | }; | 109 | }; |
| 110 | pyproject-nix = { | ||
| 111 | url = "github:pyproject-nix/pyproject.nix"; | ||
| 112 | inputs.nixpkgs.follows = "nixpkgs"; | ||
| 113 | }; | ||
| 114 | uv2nix = { | ||
| 115 | url = "github:pyproject-nix/uv2nix"; | ||
| 116 | inputs.pyproject-nix.follows = "pyproject-nix"; | ||
| 117 | inputs.nixpkgs.follows = "nixpkgs"; | ||
| 118 | }; | ||
| 119 | pyproject-build-systems = { | ||
| 120 | url = "github:pyproject-nix/build-system-pkgs"; | ||
| 121 | inputs.pyproject-nix.follows = "pyproject-nix"; | ||
| 122 | inputs.uv2nix.follows = "uv2nix"; | ||
| 123 | inputs.nixpkgs.follows = "nixpkgs"; | ||
| 124 | }; | ||
| 125 | gitignore = { | ||
| 126 | type = "github"; | ||
| 127 | owner = "hercules-ci"; | ||
| 128 | repo = "gitignore.nix"; | ||
| 129 | inputs.nixpkgs.follows = "nixpkgs"; | ||
| 130 | }; | ||
| 126 | 131 | ||
| 127 | ca-util = { | 132 | ca-util = { |
| 128 | type = "gitlab"; | 133 | type = "gitlab"; |
| 129 | owner = "gkleen"; | 134 | owner = "gkleen"; |
| 130 | repo = "ca"; | 135 | repo = "ca"; |
| 131 | ref = "v3.1.3"; | 136 | ref = "v3.1.6"; |
| 132 | inputs = { | 137 | inputs = { |
| 138 | pyproject-nix.follows = "pyproject-nix"; | ||
| 139 | uv2nix.follows = "uv2nix"; | ||
| 133 | nixpkgs.follows = "nixpkgs"; | 140 | nixpkgs.follows = "nixpkgs"; |
| 134 | poetry2nix.follows = "poetry2nix"; | ||
| 135 | }; | 141 | }; |
| 136 | }; | 142 | }; |
| 137 | backup-utils = { | 143 | backup-utils = { |
| 138 | type = "gitlab"; | 144 | type = "gitlab"; |
| 139 | owner = "gkleen"; | 145 | owner = "gkleen"; |
| 140 | repo = "backup-utils"; | 146 | repo = "backup-utils"; |
| 141 | ref = "v0.1.6"; | 147 | ref = "v0.1.7"; |
| 142 | inputs = { | 148 | inputs = { |
| 143 | nixpkgs.follows = "nixpkgs"; | 149 | nixpkgs.follows = "nixpkgs"; |
| 144 | poetry2nix.follows = "poetry2nix"; | 150 | pyproject-nix.follows = "pyproject-nix"; |
| 151 | uv2nix.follows = "uv2nix"; | ||
| 152 | pyproject-build-systems.follows = "pyproject-build-systems"; | ||
| 145 | }; | 153 | }; |
| 146 | }; | 154 | }; |
| 147 | prometheus-borg-exporter = { | 155 | prometheus-borg-exporter = { |
| 148 | type = "gitlab"; | 156 | type = "gitlab"; |
| 149 | owner = "gkleen"; | 157 | owner = "gkleen"; |
| 150 | repo = "prometheus-borg-exporter"; | 158 | repo = "prometheus-borg-exporter"; |
| 151 | ref = "main"; | 159 | ref = "v1.1.1"; |
| 152 | inputs = { | 160 | inputs = { |
| 153 | nixpkgs.follows = "nixpkgs"; | 161 | nixpkgs.follows = "nixpkgs"; |
| 154 | poetry2nix.follows = "poetry2nix"; | 162 | pyproject-nix.follows = "pyproject-nix"; |
| 163 | uv2nix.follows = "uv2nix"; | ||
| 164 | pyproject-build-systems.follows = "pyproject-build-systems"; | ||
| 165 | gitignore.follows = "gitignore"; | ||
| 155 | }; | 166 | }; |
| 156 | }; | 167 | }; |
| 157 | nixos-hardware = { | 168 | nixos-hardware = { |
| @@ -166,25 +177,64 @@ | |||
| 166 | repo = "impermanence"; | 177 | repo = "impermanence"; |
| 167 | ref = "master"; | 178 | ref = "master"; |
| 168 | }; | 179 | }; |
| 169 | waybar = { | 180 | nixVirt = { |
| 170 | type = "github"; | 181 | type = "github"; |
| 171 | owner = "gkleen"; | 182 | owner = "AshleyYakeley"; |
| 172 | repo = "Waybar"; | 183 | repo = "NixVirt"; |
| 173 | ref = "feat/privacy-ignore"; | 184 | inputs.nixpkgs.follows = "nixpkgs"; |
| 185 | }; | ||
| 186 | niri-flake = { | ||
| 187 | type = "github"; | ||
| 188 | owner = "epireyn"; | ||
| 189 | repo = "niri-flake"; | ||
| 190 | ref = "main"; | ||
| 174 | inputs = { | 191 | inputs = { |
| 175 | nixpkgs.follows = "nixpkgs"; | 192 | nixpkgs.follows = "nixpkgs"; |
| 176 | flake-compat.follows = "flake-compat"; | 193 | niri-unstable = { |
| 194 | type = "github"; | ||
| 195 | owner = "gkleen"; | ||
| 196 | repo = "niri"; | ||
| 197 | ref = "fix/locked-monitor-control"; | ||
| 198 | }; | ||
| 177 | }; | 199 | }; |
| 178 | }; | 200 | }; |
| 179 | nixVirt = { | 201 | nix-monitored = { |
| 180 | type = "github"; | 202 | type = "github"; |
| 181 | owner = "AshleyYakeley"; | 203 | owner = "ners"; |
| 182 | repo = "NixVirt"; | 204 | repo = "nix-monitored"; |
| 205 | ref = "master"; | ||
| 206 | inputs = { | ||
| 207 | nixpkgs.follows = "nixpkgs"; | ||
| 208 | }; | ||
| 209 | }; | ||
| 210 | lanzaboote = { | ||
| 211 | type = "github"; | ||
| 212 | owner = "nix-community"; | ||
| 213 | repo = "lanzaboote"; | ||
| 214 | ref = "v1.1.0"; | ||
| 215 | |||
| 216 | inputs.nixpkgs.follows = "nixpkgs"; | ||
| 217 | }; | ||
| 218 | niri-autoselect-portal = { | ||
| 219 | url = "git+https://codeberg.org/debugloop/niri-autoselect-portal.git"; | ||
| 220 | |||
| 221 | inputs.nixpkgs.follows = "nixpkgs"; | ||
| 222 | }; | ||
| 223 | nix-output-monitor = { | ||
| 224 | url = "git+https://code.maralorn.de/maralorn/nix-output-monitor.git"; | ||
| 225 | |||
| 226 | inputs = { | ||
| 227 | nixpkgs.follows = "nixpkgs"; | ||
| 228 | flake-utils.follows = "flake-utils"; | ||
| 229 | }; | ||
| 230 | }; | ||
| 231 | disko = { | ||
| 232 | url = "github:nix-community/disko/latest"; | ||
| 183 | inputs.nixpkgs.follows = "nixpkgs"; | 233 | inputs.nixpkgs.follows = "nixpkgs"; |
| 184 | }; | 234 | }; |
| 185 | }; | 235 | }; |
| 186 | 236 | ||
| 187 | outputs = { self, nixpkgs, home-manager, sops-nix, deploy-rs, nvfetcher, ... }@inputs: | 237 | outputs = { self, nixpkgs, home-manager, sops-nix, deploy-rs, nvfetcher, niri-flake, ... }@inputs: |
| 188 | let | 238 | let |
| 189 | inherit (builtins) attrNames attrValues elemAt toJSON isNull pathExists; | 239 | inherit (builtins) attrNames attrValues elemAt toJSON isNull pathExists; |
| 190 | inherit (nixpkgs) lib; | 240 | inherit (nixpkgs) lib; |
| @@ -249,7 +299,7 @@ | |||
| 249 | (inputs: inputs // { inherit userName; }) | 299 | (inputs: inputs // { inherit userName; }) |
| 250 | (outputs: { _file = dir + "/${path}"; } | 300 | (outputs: { _file = dir + "/${path}"; } |
| 251 | // outputs | 301 | // outputs |
| 252 | // { imports = defaultUserProfiles userName ++ (outputs.imports or []); }); | 302 | // { imports = defaultUserProfiles userName ++ (outputs.imports or []); }); |
| 253 | 303 | ||
| 254 | mkUserProfile = userName: dir: path: profileName: | 304 | mkUserProfile = userName: dir: path: profileName: |
| 255 | let | 305 | let |
| @@ -267,12 +317,13 @@ | |||
| 267 | mkAccountModule = dir: path: accountName: | 317 | mkAccountModule = dir: path: accountName: |
| 268 | let | 318 | let |
| 269 | userName = accountUserName accountName; | 319 | userName = accountUserName accountName; |
| 320 | hostName = accountHostName accountName; | ||
| 270 | in overrideModule | 321 | in overrideModule |
| 271 | (import (dir + "/${path}")) | 322 | (import (dir + "/${path}")) |
| 272 | (inputs: inputs // { inherit userName; }) | 323 | (inputs: inputs // { inherit userName hostName; }) |
| 273 | (outputs: { _file = dir + "/${path}"; } | 324 | (outputs: { _file = dir + "/${path}"; } |
| 274 | // outputs | 325 | // outputs |
| 275 | // { imports = [self.nixosModules.users.${userName} or ({...}: { imports = defaultUserProfiles userName; })] ++ (outputs.imports or []); }); | 326 | // { imports = [self.nixosModules.users.${userName} or ({...}: { imports = defaultUserProfiles userName; })] ++ (outputs.imports or []); }); |
| 276 | 327 | ||
| 277 | systemsSelector = "x86_64-linux"; | 328 | systemsSelector = "x86_64-linux"; |
| 278 | systems = filter (system: !(isNull (builtins.match systemsSelector system))) nixpkgs.lib.systems.flakeExposed; | 329 | systems = filter (system: !(isNull (builtins.match systemsSelector system))) nixpkgs.lib.systems.flakeExposed; |
| @@ -285,7 +336,7 @@ | |||
| 285 | forAllUsers = genAttrs (unique (map accountUserName (attrNames self.nixosModules.accounts))); | 336 | forAllUsers = genAttrs (unique (map accountUserName (attrNames self.nixosModules.accounts))); |
| 286 | 337 | ||
| 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)); | 338 | 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; })); | 339 | # 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)))); | 340 | 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 { | 341 | installerShells = system: pkgs: mapAttrs (installerName: config: pkgs.callPackage ./installer/shell.nix { |
| 291 | inherit system installerName config; | 342 | inherit system installerName config; |
| @@ -322,18 +373,23 @@ | |||
| 322 | nixosConfigurations = installerNixosConfigurations // nixImport rec { dir = ./hosts; _import = mkNixosConfiguration [] dir; }; | 373 | nixosConfigurations = installerNixosConfigurations // nixImport rec { dir = ./hosts; _import = mkNixosConfiguration [] dir; }; |
| 323 | 374 | ||
| 324 | homeModules = nixImport rec { dir = ./home-modules; }; | 375 | 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)); | 376 | homeConfigurations = listToAttrs (concatLists (mapAttrsToList (hostname: nixosConfig: mapAttrsToList (username: nameValuePair "${username}@${hostname}") nixosConfig.config.home-manager.users) self.nixosConfigurations)); |
| 326 | 377 | ||
| 327 | overlays = mapAttrs (_name: path: mkOverlay path) overlayPaths; | 378 | overlays = mapAttrs (_name: path: mkOverlay path) overlayPaths; |
| 328 | 379 | ||
| 329 | packages = forAllSystems (system: systemPkgs: nixImport rec { dir = ./tools; _import = _path: name: import "${toString dir}/${name}" ({ inherit system; } // inputs); }); | 380 | packages = forAllSystems (system: systemPkgs: nixImport rec { dir = ./tools; _import = name: _base: import (dir + "/${name}") ({ inherit system; } // inputs); }); |
| 330 | 381 | ||
| 331 | # packages = mapAttrs (_name: filterAttrs (_name: isDerivation)) packages; | 382 | # packages = mapAttrs (_name: filterAttrs (_name: isDerivation)) packages; |
| 332 | # packages' = mapAttrs (_name: filterAttrs (_name: value: !(isDerivation value))) packages; | 383 | # packages' = mapAttrs (_name: filterAttrs (_name: value: !(isDerivation value))) packages; |
| 333 | 384 | ||
| 334 | legacyPackages = forAllSystems (system: systemPkgs: systemPkgs.override { overlays = attrValues self.overlays; }); | 385 | legacyPackages = forAllSystems (system: systemPkgs: systemPkgs.override { overlays = attrValues self.overlays; }); |
| 335 | 386 | ||
| 336 | apps = foldr recursiveUpdate {} [startVMs activateNixosConfigurations activateHomeManagerConfigurations]; | 387 | apps = foldr recursiveUpdate {} [ |
| 388 | #startVMs | ||
| 389 | activateNixosConfigurations activateHomeManagerConfigurations | ||
| 390 | ]; | ||
| 391 | |||
| 392 | lib = nixImport rec { dir = ./lib; _import = name: _base: import (dir + "/${name}") inputs; }; | ||
| 337 | 393 | ||
| 338 | devShells = forAllSystems (system: systemPkgs: { default = import ./shell.nix ({ inherit system; } // inputs); } // installerShells system systemPkgs); | 394 | devShells = forAllSystems (system: systemPkgs: { default = import ./shell.nix ({ inherit system; } // inputs); } // installerShells system systemPkgs); |
| 339 | 395 | ||
| @@ -358,10 +414,10 @@ | |||
| 358 | # path = activateHomeManager (self.nixosConfigurations.${hostname}.config.nixpkgs.system) usercfg.home; | 414 | # path = activateHomeManager (self.nixosConfigurations.${hostname}.config.nixpkgs.system) usercfg.home; |
| 359 | # }) self.nixosConfigurations.${hostname}.config.home-manager.users); | 415 | # }) self.nixosConfigurations.${hostname}.config.home-manager.users); |
| 360 | }) (nixImport { dir = ./hosts; _import = (_path: name: name); }); | 416 | }) (nixImport { dir = ./hosts; _import = (_path: name: name); }); |
| 361 | overrides = if pathExists ./deploy then nixImport { dir = ./deploy; _import = path: _name: import (./deploy + "/${path}") inputs; } else {}; | 417 | 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); | 418 | 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)); | 419 | in mapAttrs (_n: v: if v ? "profiles" then v // { profiles = filterEnabled v.profiles; } else v) (filterEnabled (recursiveUpdate defaults overrides)); |
| 364 | 420 | ||
| 365 | checks = builtins.mapAttrs (system: deployLib: deployLib.deployChecks self.deploy) deploy-rs.lib; | 421 | # checks = builtins.mapAttrs (system: deployLib: deployLib.deployChecks self.deploy) deploy-rs.lib; |
| 366 | }; | 422 | }; |
| 367 | } | 423 | } |
