|
1 | 1 | { flake-utils }: {
|
2 | 2 | fleetConfiguration = { data, nixpkgs, hosts, ... }@allConfig:
|
3 | 3 | let
|
| 4 | + hostNames = nixpkgs.lib.attrNames hosts; |
4 | 5 | config = builtins.removeAttrs allConfig [ "nixpkgs" "data" ];
|
5 | 6 | fleetLib = import ./fleetLib.nix {
|
6 |
| - inherit nixpkgs hosts; |
| 7 | + inherit nixpkgs hostNames; |
7 | 8 | };
|
8 | 9 | in
|
9 |
| - nixpkgs.lib.genAttrs flake-utils.lib.defaultSystems (system: rec { |
10 |
| - root = nixpkgs.lib.evalModules { |
11 |
| - modules = (import ../modules/fleet/_modules.nix) ++ [ config data ]; |
12 |
| - specialArgs = { |
13 |
| - inherit nixpkgs; |
14 |
| - fleet = fleetLib; |
| 10 | + nixpkgs.lib.genAttrs flake-utils.lib.defaultSystems (system: |
| 11 | + let |
| 12 | + root = nixpkgs.lib.evalModules { |
| 13 | + modules = (import ../modules/fleet/_modules.nix) ++ [ config data ]; |
| 14 | + specialArgs = { |
| 15 | + inherit nixpkgs fleetLib; |
| 16 | + }; |
15 | 17 | };
|
16 |
| - }; |
17 |
| - configuredHosts = root.config.hosts; |
18 |
| - configuredSecrets = root.config.secrets; |
19 |
| - configuredSystems = nixpkgs.lib.listToAttrs ( |
20 |
| - map |
21 |
| - ( |
22 |
| - name: { |
23 |
| - inherit name; |
24 |
| - value = nixpkgs.lib.nixosSystem { |
25 |
| - system = configuredHosts.${name}.system; |
26 |
| - modules = configuredHosts.${name}.modules ++ ( |
27 |
| - if configuredHosts.${name}.system == "aarch64-linux" then [ (nixpkgs + "/nixos/modules/installer/sd-card/sd-image-aarch64-installer.nix") ] |
28 |
| - else [ ] |
29 |
| - ) ++ [ |
30 |
| - ({ ... }: { |
31 |
| - nixpkgs.system = system; |
32 |
| - nixpkgs.localSystem.system = system; |
33 |
| - nixpkgs.crossSystem = if system == configuredHosts.${name}.system then null else { |
34 |
| - system = configuredHosts.${name}.system; |
35 |
| - }; |
36 |
| - }) |
37 |
| - ]; |
38 |
| - specialArgs = { |
39 |
| - fleet = fleetLib.hostsToAttrs (host: configuredSystems.${host}.config); |
| 18 | + failedAssertions = map (x: x.message) (nixpkgs.lib.filter (x: !x.assertion) root.config.assertions); |
| 19 | + rootAssertWarn = |
| 20 | + if failedAssertions != [ ] |
| 21 | + then throw "Failed assertions:\n${nixpkgs.lib.concatStringsSep "\n" (map (x: "- ${x}") failedAssertions)}" |
| 22 | + else nixpkgs.lib.showWarnings root.config.warnings root; |
| 23 | + in |
| 24 | + rec { |
| 25 | + configuredHosts = rootAssertWarn.config.hosts; |
| 26 | + configuredSecrets = rootAssertWarn.config.secrets; |
| 27 | + configuredSystems = nixpkgs.lib.listToAttrs ( |
| 28 | + map |
| 29 | + ( |
| 30 | + name: { |
| 31 | + inherit name; |
| 32 | + value = nixpkgs.lib.nixosSystem { |
| 33 | + system = configuredHosts.${name}.system; |
| 34 | + modules = configuredHosts.${name}.modules ++ ( |
| 35 | + if configuredHosts.${name}.system == "aarch64-linux" then [ (nixpkgs + "/nixos/modules/installer/sd-card/sd-image-aarch64-installer.nix") ] |
| 36 | + else [ ] |
| 37 | + ) ++ [ |
| 38 | + ({ ... }: { |
| 39 | + nixpkgs.system = system; |
| 40 | + nixpkgs.localSystem.system = system; |
| 41 | + nixpkgs.crossSystem = if system == configuredHosts.${name}.system then null else { |
| 42 | + system = configuredHosts.${name}.system; |
| 43 | + }; |
| 44 | + }) |
| 45 | + ]; |
| 46 | + specialArgs = { |
| 47 | + inherit fleetLib; |
| 48 | + fleet = fleetLib.hostsToAttrs (host: configuredSystems.${host}.config); |
| 49 | + }; |
40 | 50 | };
|
41 |
| - }; |
42 |
| - } |
43 |
| - ) |
44 |
| - (builtins.attrNames root.config.hosts) |
45 |
| - ); #nixpkgs.lib.nixosSystem {} |
46 |
| - }); |
| 51 | + } |
| 52 | + ) |
| 53 | + (builtins.attrNames rootAssertWarn.config.hosts) |
| 54 | + ); #nixpkgs.lib.nixosSystem {} |
| 55 | + }); |
47 | 56 | }
|
0 commit comments