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