|
77 | 77 | { self |
78 | 78 | , nixpkgs |
79 | 79 | , nixpkgs-unstable |
80 | | - , nixpkgs-2105 |
81 | | - , nixpkgs-2111 |
82 | | - , nixpkgs-2205 |
83 | | - , nixpkgs-2211 |
84 | | - , nixpkgs-2305 |
85 | | - , nixpkgs-2311 |
86 | | - , nixpkgs-2405 |
87 | 80 | , flake-compat |
88 | 81 | , ... |
89 | 82 | }@inputs: |
|
92 | 85 |
|
93 | 86 | ifdLevel = 3; |
94 | 87 | runningHydraEvalTest = false; |
95 | | - compiler = "ghc928"; |
| 88 | + defaultCompiler = "ghc928"; |
96 | 89 | config = import ./config.nix; |
97 | 90 |
|
98 | 91 | inherit (nixpkgs) lib; |
99 | 92 |
|
100 | 93 | traceNames = prefix: builtins.mapAttrs (n: v: |
101 | 94 | if builtins.isAttrs v |
102 | | - then if v ? type && v.type == "derivation" |
103 | | - then builtins.trace (prefix + n) v |
104 | | - else traceNames (prefix + n + ".") v |
105 | | - else v); |
| 95 | + then if v ? type && v.type == "derivation" |
| 96 | + then builtins.trace (prefix + n) v |
| 97 | + else traceNames (prefix + n + ".") v |
| 98 | + else v); |
106 | 99 |
|
107 | 100 | traceHydraJobs = x: x // { inherit (traceNames "" x) hydraJobs; }; |
108 | 101 |
|
109 | 102 | # systems supported by haskell.nix |
110 | 103 | systems = [ |
111 | 104 | "x86_64-linux" |
112 | | - ] ++ (if runningHydraEvalTest then [] else [ |
| 105 | + ] ++ (if runningHydraEvalTest then [ ] else [ |
113 | 106 | "x86_64-darwin" |
114 | 107 | "aarch64-darwin" |
115 | 108 | ]); |
|
128 | 121 | filterDerivations; |
129 | 122 |
|
130 | 123 | flake = { |
131 | | - inherit config; |
132 | | - overlay = self.overlays.combined; |
133 | | - overlays = import ./overlays { sources = inputs; }; |
| 124 | + inherit config; |
| 125 | + overlay = self.overlays.combined; |
| 126 | + overlays = import ./overlays { sources = inputs; }; |
134 | 127 |
|
135 | | - internal = { |
136 | | - nixpkgsArgs = { |
137 | | - inherit config; |
138 | | - overlays = [ self.overlay ]; |
139 | | - }; |
| 128 | + internal = { |
| 129 | + nixpkgsArgs = { |
| 130 | + inherit config; |
| 131 | + overlays = [ self.overlay ]; |
| 132 | + }; |
140 | 133 |
|
141 | | - sources = inputs; |
| 134 | + sources = inputs; |
142 | 135 |
|
143 | | - overlaysOverrideable = |
144 | | - lib.warn |
145 | | - "Using this attribute is deprecated. Import ${./overlays} directly or use the flake overlays output with override-inut." |
146 | | - (import ./overlays); |
| 136 | + overlaysOverrideable = |
| 137 | + lib.warn |
| 138 | + "Using this attribute is deprecated. Import ${./overlays} directly or use the flake overlays output with override-inut." |
| 139 | + (import ./overlays); |
147 | 140 |
|
148 | | - # Compatibility with old default.nix |
149 | | - compat = |
150 | | - lib.warn |
151 | | - "Using this attribute is deprecated. You can pass the same arguments to ${./default.nix} instead" |
152 | | - (import ./default.nix); |
153 | | - }; |
| 141 | + # Compatibility with old default.nix |
| 142 | + compat = |
| 143 | + lib.warn |
| 144 | + "Using this attribute is deprecated. You can pass the same arguments to ${./default.nix} instead" |
| 145 | + (import ./default.nix); |
| 146 | + }; |
154 | 147 |
|
155 | | - legacyPackages = forEachSystem (system: |
156 | | - import nixpkgs { |
157 | | - inherit config; |
158 | | - overlays = [ self.overlay ]; |
159 | | - localSystem = { inherit system; }; |
160 | | - }); |
| 148 | + legacyPackages = forEachSystem (system: |
| 149 | + import nixpkgs { |
| 150 | + inherit config; |
| 151 | + overlays = [ self.overlay ]; |
| 152 | + localSystem = { inherit system; }; |
| 153 | + }); |
161 | 154 |
|
162 | | - legacyPackagesUnstable = forEachSystem (system: |
163 | | - import nixpkgs-unstable { |
164 | | - inherit config; |
165 | | - overlays = [ self.overlay ]; |
166 | | - localSystem = { inherit system; }; |
167 | | - }); |
| 155 | + legacyPackagesUnstable = forEachSystem (system: |
| 156 | + import nixpkgs-unstable { |
| 157 | + inherit config; |
| 158 | + overlays = [ self.overlay ]; |
| 159 | + localSystem = { inherit system; }; |
| 160 | + }); |
168 | 161 |
|
169 | | - # Exposed so CI can check that `allow-import-from-derivation=false` works |
170 | | - # for core of haskell.nix E.g. this should always work: |
171 | | - # nix build .#roots.x86_64-linux --accept-flake-config --option allow-import-from-derivation false |
172 | | - roots = forEachSystem (system: |
173 | | - self.legacyPackagesUnstable.${system}.haskell-nix.roots compiler); |
| 162 | + # Exposed so CI can check that `allow-import-from-derivation=false` works |
| 163 | + # for core of haskell.nix E.g. this should always work: |
| 164 | + # nix build .#roots.x86_64-linux --accept-flake-config --option allow-import-from-derivation false |
| 165 | + roots = forEachSystem (system: |
| 166 | + self.legacyPackagesUnstable.${system}.haskell-nix.roots defaultCompiler); |
174 | 167 |
|
175 | | - # Note: `nix flake check` evaluates outputs for all platforms, and haskell.nix |
176 | | - # uses IFD heavily, you have to have the ability to build for all platforms |
177 | | - # supported by haskell.nix, e.g. with remote builders, in order to check this flake. |
178 | | - # If you want to run the tests for just your platform, run `./test/tests.sh` or |
179 | | - # `nix-build -A checks.$PLATFORM` |
180 | | - checks = forEachSystemPkgs (pkgs: |
181 | | - builtins.listToAttrs ( |
182 | | - map |
183 | | - (pkg: { name = pkg.name; value = pkg; }) |
184 | | - (lib.collect |
185 | | - lib.isDerivation |
186 | | - (import ./test { |
187 | | - haskellNix.sources = inputs; |
188 | | - haskellNix.nixpkgsArgs = nixpkgsArgs; |
189 | | - compiler-nix-name = compiler; |
190 | | - inherit pkgs; |
191 | | - }) |
| 168 | + # Note: `nix flake check` evaluates outputs for all platforms, and haskell.nix |
| 169 | + # uses IFD heavily, you have to have the ability to build for all platforms |
| 170 | + # supported by haskell.nix, e.g. with remote builders, in order to check this flake. |
| 171 | + # If you want to run the tests for just your platform, run `./test/tests.sh` or |
| 172 | + # `nix-build -A checks.$PLATFORM` |
| 173 | + checks = forEachSystemPkgs (pkgs: |
| 174 | + builtins.listToAttrs ( |
| 175 | + map |
| 176 | + (pkg: { name = pkg.name; value = pkg; }) |
| 177 | + (lib.collect |
| 178 | + lib.isDerivation |
| 179 | + (import ./test { |
| 180 | + haskellNix.sources = inputs; |
| 181 | + haskellNix.nixpkgsArgs = nixpkgsArgs; |
| 182 | + compiler-nix-name = defaultCompiler; |
| 183 | + inherit pkgs; |
| 184 | + }) |
192 | 185 | ) |
193 | | - ) |
| 186 | + ) |
| 187 | + ); |
| 188 | + |
| 189 | + # NOTE: these are the hix cli utilities, which is a separate thing from |
| 190 | + # the hix.nix overlays (which extends haskell.nix with hixProject). |
| 191 | + packages = forEachSystemPkgs (pkgs: |
| 192 | + (import ./hix/default.nix { inherit pkgs; }).apps |
194 | 193 | ); |
195 | 194 |
|
196 | | - # NOTE: these are the hix cli utilities, which is a separate thing from |
197 | | - # the hix.nix overlays (which extends haskell.nix with hixProject). |
198 | | - packages = forEachSystemPkgs (pkgs: |
199 | | - (import ./hix/default.nix { inherit pkgs; }).apps |
200 | | - ); |
201 | | - apps = forEachSystemPkgs (pkgs: |
202 | | - builtins.mapAttrs (name: exe: { |
203 | | - type = "app"; |
204 | | - program = exe + "/bin/${name}"; |
205 | | - }) pkgs.haskell-nix.nix-tools-unchecked.exes |
206 | | - ); |
| 195 | + apps = forEachSystemPkgs (pkgs: |
| 196 | + builtins.mapAttrs |
| 197 | + (name: exe: { |
| 198 | + type = "app"; |
| 199 | + program = exe + "/bin/${name}"; |
| 200 | + }) |
| 201 | + pkgs.haskell-nix.nix-tools-unchecked.exes |
| 202 | + ); |
207 | 203 |
|
208 | | - allJobs = forEachSystem (system: |
209 | | - stripAttrsForHydra (filterDerivations ( |
210 | | - # This is awkward. |
211 | | - import ./ci.nix { |
212 | | - inherit ifdLevel system; |
213 | | - haskellNix = self; |
214 | | - }))); |
| 204 | + allJobs = forEachSystem (system: |
| 205 | + stripAttrsForHydra (filterDerivations ( |
| 206 | + # This is awkward. |
| 207 | + import ./ci.nix { |
| 208 | + inherit ifdLevel system; |
| 209 | + haskellNix = self; |
| 210 | + } |
| 211 | + ))); |
215 | 212 |
|
216 | | - requiredJobs = forEachSystem (system: |
217 | | - let |
218 | | - inherit (self.legacyPackages.${system}) releaseTools; |
219 | | - in |
220 | | - lib.concatMapAttrs (nixpkgsVer: |
221 | | - lib.concatMapAttrs (compiler-nix-name: |
222 | | - lib.concatMapAttrs (crossPlatform: ghcJobs: |
223 | | - let |
224 | | - name = "required-${nixpkgsVer}-${compiler-nix-name}-${crossPlatform}"; |
225 | | - value = releaseTools.aggregate { |
| 213 | + requiredJobs = forEachSystem (system: |
| 214 | + let |
| 215 | + inherit (self.legacyPackages.${system}) releaseTools; |
| 216 | + in |
| 217 | + lib.concatMapAttrs |
| 218 | + (nixpkgsVer: |
| 219 | + lib.concatMapAttrs (compiler-nix-name: |
| 220 | + lib.concatMapAttrs (crossPlatform: ghcJobs: |
| 221 | + let |
| 222 | + name = "required-${nixpkgsVer}-${compiler-nix-name}-${crossPlatform}"; |
| 223 | + value = releaseTools.aggregate { |
226 | 224 | name = "haskell.nix-${nixpkgsVer}-${compiler-nix-name}-${crossPlatform}"; |
227 | 225 | meta.description = "All ${nixpkgsVer} ${compiler-nix-name} ${crossPlatform} jobs"; |
228 | 226 | constituents = lib.collect lib.isDerivation ghcJobs; |
229 | | - }; |
230 | | - in |
231 | | - lib.optionalAttrs |
232 | | - (crossPlatform != "recurseForDerivations" && crossPlatform != "meta") |
233 | | - { ${name} = value; }) |
| 227 | + }; |
| 228 | + in |
| 229 | + lib.optionalAttrs |
| 230 | + (crossPlatform != "recurseForDerivations" && crossPlatform != "meta") |
| 231 | + { ${name} = value; }) |
234 | 232 | ) |
235 | 233 | ) |
236 | 234 | self.allJobs.${system} |
237 | | - ); |
| 235 | + ); |
238 | 236 |
|
239 | | - hydraJobs = forEachSystem (system: |
240 | | - let |
241 | | - # Include hydraJobs from nix-tools subflake. |
242 | | - # NOTE: These derivations do not depend on the haskell.nix in ./. but |
243 | | - # on the version of haskell.nix locked in the subflake. They are |
244 | | - # evaluated within their own flake and independently of anything |
245 | | - # else. Here we only expose them in the main flake. |
246 | | - nix-tools-hydraJobs = |
247 | | - let cf = callFlake { |
248 | | - inherit system; |
249 | | - pkgs = self.legacyPackages.${system}; |
250 | | - src = ./nix-tools; |
251 | | - }; |
252 | | - in cf.defaultNix.hydraJobs; |
253 | | - in |
254 | | - self.allJobs.${system} |
| 237 | + hydraJobs = forEachSystem (system: |
| 238 | + let |
| 239 | + # Include hydraJobs from nix-tools subflake. |
| 240 | + # NOTE: These derivations do not depend on the haskell.nix in ./. but |
| 241 | + # on the version of haskell.nix locked in the subflake. They are |
| 242 | + # evaluated within their own flake and independently of anything |
| 243 | + # else. Here we only expose them in the main flake. |
| 244 | + nix-tools-hydraJobs = |
| 245 | + let |
| 246 | + cf = callFlake { |
| 247 | + inherit system; |
| 248 | + pkgs = self.legacyPackages.${system}; |
| 249 | + src = ./nix-tools; |
| 250 | + }; |
| 251 | + in |
| 252 | + cf.defaultNix.hydraJobs; |
| 253 | + in |
| 254 | + self.allJobs.${system} |
255 | 255 | // lib.optionalAttrs (ifdLevel > 2) |
256 | | - { nix-tools = nix-tools-hydraJobs.${system} or {}; } |
257 | | - ); |
| 256 | + { nix-tools = nix-tools-hydraJobs.${system} or { }; } |
| 257 | + ); |
258 | 258 |
|
259 | | - devShells = forEachSystemPkgs (pkgs: |
260 | | - let inherit (pkgs) mkShell nixUnstable cabal-install haskell-nix; |
261 | | - in { |
262 | | - default = |
263 | | - mkShell { |
264 | | - buildInputs = [ |
265 | | - nixUnstable |
266 | | - cabal-install |
267 | | - haskell-nix.compiler.${compiler} |
268 | | - ]; |
269 | | - }; |
| 259 | + devShells = forEachSystemPkgs (pkgs: |
| 260 | + let |
| 261 | + mkHaskellNixShell = compiler-nix-name: |
| 262 | + pkgs.mkShell { |
| 263 | + buildInputs = [ |
| 264 | + pkgs.nixVersions.latest |
| 265 | + pkgs.haskell-nix.cabal-install.${compiler-nix-name} |
| 266 | + pkgs.haskell-nix.compiler.${compiler-nix-name} |
| 267 | + ]; |
| 268 | + }; |
| 269 | + shells = lib.genAttrs ( |
| 270 | + # Exclude old versions of GHC to speed up `nix flake check` |
| 271 | + lib.attrNames ( |
| 272 | + lib.removeAttrs pkgs.haskell-nix.compiler |
| 273 | + ([ "ghc844" ] ++ |
| 274 | + [ "ghc861" "ghc862" "ghc863" "ghc864" ] ++ |
| 275 | + [ "ghc881" "ghc882" "ghc883" ] ++ |
| 276 | + [ "ghc8101" "ghc8102" "ghc8103" "ghc8104" "ghc810420210212" "ghc8105" "ghc8106" ] ++ |
| 277 | + [ "ghc901" ] ++ [ "ghc921" "ghc922" "ghc923" ]) |
| 278 | + )) |
| 279 | + mkHaskellNixShell; |
| 280 | + in |
| 281 | + shells // { default = shells.${defaultCompiler}; }); |
| 282 | + }; |
| 283 | + |
| 284 | + in |
| 285 | + traceHydraJobs (lib.recursiveUpdate flake (lib.optionalAttrs (ifdLevel > 2) |
| 286 | + ( |
| 287 | + let pkgs = nixpkgs.legacyPackages."x86_64-linux"; in |
| 288 | + { |
| 289 | + hydraJobs.nix-tools = pkgs.releaseTools.aggregate { |
| 290 | + name = "nix-tools"; |
| 291 | + constituents = (if runningHydraEvalTest then [ ] else [ |
| 292 | + "aarch64-darwin.nix-tools.static.zipped.nix-tools-static" |
| 293 | + "x86_64-darwin.nix-tools.static.zipped.nix-tools-static" |
| 294 | + "aarch64-darwin.nix-tools.static.zipped.nix-tools-static-no-ifd" |
| 295 | + "x86_64-darwin.nix-tools.static.zipped.nix-tools-static-no-ifd" |
| 296 | + ]) ++ [ |
| 297 | + "x86_64-linux.nix-tools.static.zipped.nix-tools-static" |
| 298 | + "x86_64-linux.nix-tools.static.zipped.nix-tools-static-arm64" |
| 299 | + "x86_64-linux.nix-tools.static.zipped.nix-tools-static-no-ifd" |
| 300 | + "x86_64-linux.nix-tools.static.zipped.nix-tools-static-arm64-no-ifd" |
| 301 | + (pkgs.writeText "gitrev" (self.rev or "0000000000000000000000000000000000000000")) |
| 302 | + ]; |
| 303 | + }; |
270 | 304 | } |
271 | | - // |
272 | | - builtins.mapAttrs |
273 | | - (compiler-nix-name: compiler: |
274 | | - mkShell { |
275 | | - buildInputs = [ |
276 | | - compiler |
277 | | - haskell-nix.cabal-install.${compiler-nix-name} |
278 | | - ]; |
279 | | - }) |
280 | | - ( # Exclude old versions of GHC to speed up `nix flake check` |
281 | | - builtins.removeAttrs haskell-nix.compiler |
282 | | - [ "ghc844" |
283 | | - "ghc861" "ghc862" "ghc863" "ghc864" |
284 | | - "ghc881" "ghc882" "ghc883" |
285 | | - "ghc8101" "ghc8102" "ghc8103" "ghc8104" "ghc8105" "ghc8106" "ghc810420210212" |
286 | | - "ghc901" |
287 | | - "ghc921" "ghc922" "ghc923"]) |
288 | | - ); |
289 | | - }; in with (import nixpkgs { system = "x86_64-linux"; }); |
290 | | - traceHydraJobs (lib.recursiveUpdate flake (lib.optionalAttrs (ifdLevel > 2) { |
291 | | - hydraJobs.nix-tools = pkgs.releaseTools.aggregate { |
292 | | - name = "nix-tools"; |
293 | | - constituents = (if runningHydraEvalTest then [] else [ |
294 | | - "aarch64-darwin.nix-tools.static.zipped.nix-tools-static" |
295 | | - "x86_64-darwin.nix-tools.static.zipped.nix-tools-static" |
296 | | - "aarch64-darwin.nix-tools.static.zipped.nix-tools-static-no-ifd" |
297 | | - "x86_64-darwin.nix-tools.static.zipped.nix-tools-static-no-ifd" |
298 | | - ]) ++ [ |
299 | | - "x86_64-linux.nix-tools.static.zipped.nix-tools-static" |
300 | | - "x86_64-linux.nix-tools.static.zipped.nix-tools-static-arm64" |
301 | | - "x86_64-linux.nix-tools.static.zipped.nix-tools-static-no-ifd" |
302 | | - "x86_64-linux.nix-tools.static.zipped.nix-tools-static-arm64-no-ifd" |
303 | | - (writeText "gitrev" (self.rev or "0000000000000000000000000000000000000000")) |
304 | | - ]; |
305 | | - }; |
306 | | - })); |
| 305 | + ))); |
307 | 306 |
|
308 | 307 | # --- Flake Local Nix Configuration ---------------------------- |
309 | 308 | nixConfig = { |
310 | 309 | # This sets the flake to use the IOG nix cache. |
311 | 310 | # Nix should ask for permission before using it, |
312 | 311 | # but remove it here if you do not want it to. |
313 | | - extra-substituters = ["https://cache.iog.io"]; |
314 | | - extra-trusted-public-keys = ["hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ="]; |
| 312 | + extra-substituters = [ "https://cache.iog.io" ]; |
| 313 | + extra-trusted-public-keys = [ "hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ=" ]; |
315 | 314 | allow-import-from-derivation = "true"; |
316 | 315 | }; |
317 | 316 | } |
0 commit comments