|
11 | 11 | self, |
12 | 12 | nixpkgs, |
13 | 13 | nixlib, |
14 | | - }: let |
| 14 | + } @ inputs: let |
15 | 15 | lib = nixpkgs.lib; |
16 | 16 |
|
| 17 | + callFlake = flake: let |
| 18 | + args = |
| 19 | + inputs |
| 20 | + // { |
| 21 | + nixos-generators = self; |
| 22 | + self = subFlake; |
| 23 | + }; |
| 24 | + subFlake = (import flake).outputs args; |
| 25 | + in subFlake; |
| 26 | + |
17 | 27 | # Ensures a derivation's name can be accessed without evaluating it deeply. |
18 | 28 | # Prevents `nix flake show` from being very slow. |
19 | 29 | makeLazyDrv = name: drv: { |
|
30 | 40 | # Library modules (depend on nixlib) |
31 | 41 | { |
32 | 42 | # export all generator formats in ./formats |
33 | | - nixosModules = nixlib.lib.mapAttrs' (file: _: { |
34 | | - name = nixlib.lib.removeSuffix ".nix" file; |
35 | | - # The exported module should include the internal format* options |
36 | | - value.imports = [(./formats + "/${file}") ./format-module.nix]; |
37 | | - }) (builtins.readDir ./formats); |
| 43 | + nixosModules = |
| 44 | + { |
| 45 | + all-formats = ./all-formats.nix; |
| 46 | + } |
| 47 | + // (nixlib.lib.mapAttrs' (file: _: { |
| 48 | + name = nixlib.lib.removeSuffix ".nix" file; |
| 49 | + # The exported module should include the internal format* options |
| 50 | + value.imports = [(./formats + "/${file}") ./format-module.nix]; |
| 51 | + }) (builtins.readDir ./formats)); |
38 | 52 |
|
39 | 53 | # example usage in flakes: |
40 | 54 | # outputs = { self, nixpkgs, nixos-generators, ...}: { |
|
124 | 138 | }); |
125 | 139 |
|
126 | 140 | checks = |
127 | | - lib.genAttrs ["x86_64-linux" "aarch64-linux"] |
| 141 | + lib.recursiveUpdate |
| 142 | + (callFlake ./checks/test-all-formats-flake/flake.nix).checks |
128 | 143 | ( |
129 | | - system: let |
130 | | - allFormats = import ./checks/test-all-formats.nix { |
131 | | - inherit nixpkgs system; |
132 | | - }; |
133 | | - test-customize-format = import ./checks/test-customize-format.nix { |
134 | | - inherit nixpkgs system; |
135 | | - }; |
136 | | - in |
137 | | - lib.mapAttrs makeLazyDrv ( |
138 | | - { |
139 | | - inherit |
140 | | - (self.packages.${system}) |
141 | | - nixos-generate |
142 | | - ; |
143 | | - |
144 | | - inherit test-customize-format; |
145 | | - |
146 | | - is-formatted = import ./checks/is-formatted.nix { |
147 | | - pkgs = nixpkgs.legacyPackages.${system}; |
148 | | - }; |
149 | | - } |
150 | | - // allFormats |
151 | | - ) |
| 144 | + lib.genAttrs ["x86_64-linux" "aarch64-linux"] |
| 145 | + ( |
| 146 | + system: let |
| 147 | + allFormats = import ./checks/test-all-formats.nix { |
| 148 | + inherit nixpkgs system; |
| 149 | + }; |
| 150 | + test-customize-format = import ./checks/test-customize-format.nix { |
| 151 | + inherit nixpkgs system; |
| 152 | + }; |
| 153 | + in |
| 154 | + lib.mapAttrs makeLazyDrv ( |
| 155 | + { |
| 156 | + inherit |
| 157 | + (self.packages.${system}) |
| 158 | + nixos-generate |
| 159 | + ; |
| 160 | + |
| 161 | + inherit test-customize-format; |
| 162 | + |
| 163 | + is-formatted = import ./checks/is-formatted.nix { |
| 164 | + pkgs = nixpkgs.legacyPackages.${system}; |
| 165 | + }; |
| 166 | + } |
| 167 | + // allFormats |
| 168 | + ) |
| 169 | + ) |
152 | 170 | ); |
153 | 171 |
|
154 | 172 | devShells = forAllSystems (system: let |
|
0 commit comments