-
Notifications
You must be signed in to change notification settings - Fork 236
/
flake.nix
316 lines (289 loc) · 11.6 KB
/
flake.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
{
description = "Alternative Haskell Infrastructure for Nixpkgs";
inputs = {
nixpkgs.follows = "nixpkgs-unstable";
nixpkgs-2003 = { url = "github:NixOS/nixpkgs/nixpkgs-20.03-darwin"; };
nixpkgs-2105 = { url = "github:NixOS/nixpkgs/nixpkgs-21.05-darwin"; };
nixpkgs-2111 = { url = "github:NixOS/nixpkgs/nixpkgs-21.11-darwin"; };
nixpkgs-2205 = { url = "github:NixOS/nixpkgs/nixpkgs-22.05-darwin"; };
nixpkgs-2211 = { url = "github:NixOS/nixpkgs/nixpkgs-22.11-darwin"; };
nixpkgs-2305 = { url = "github:NixOS/nixpkgs/nixpkgs-23.05-darwin"; };
nixpkgs-2311 = { url = "github:NixOS/nixpkgs/nixpkgs-23.11-darwin"; };
nixpkgs-2405 = { url = "github:NixOS/nixpkgs/nixpkgs-24.05-darwin"; };
nixpkgs-unstable = { url = "github:NixOS/nixpkgs/nixpkgs-unstable"; };
flake-compat = { url = "github:input-output-hk/flake-compat/hkm/gitlab-fix"; flake = false; };
"hls-1.10" = { url = "github:haskell/haskell-language-server/1.10.0.0"; flake = false; };
"hls-2.0" = { url = "github:haskell/haskell-language-server/2.0.0.1"; flake = false; };
"hls-2.2" = { url = "github:haskell/haskell-language-server/2.2.0.0"; flake = false; };
"hls-2.3" = { url = "github:haskell/haskell-language-server/2.3.0.0"; flake = false; };
"hls-2.4" = { url = "github:haskell/haskell-language-server/2.4.0.1"; flake = false; };
"hls-2.5" = { url = "github:haskell/haskell-language-server/2.5.0.0"; flake = false; };
"hls-2.6" = { url = "github:haskell/haskell-language-server/2.6.0.0"; flake = false; };
"hls-2.7" = { url = "github:haskell/haskell-language-server/2.7.0.0"; flake = false; };
"hls-2.8" = { url = "github:haskell/haskell-language-server/2.8.0.0"; flake = false; };
"hls-2.9" = { url = "github:haskell/haskell-language-server/2.9.0.1"; flake = false; };
hydra.url = "hydra";
hackage = {
url = "github:input-output-hk/hackage.nix";
flake = false;
};
stackage = {
url = "github:input-output-hk/stackage.nix";
flake = false;
};
cabal-32 = {
url = "github:haskell/cabal/3.2";
flake = false;
};
cabal-34 = {
url = "github:haskell/cabal/3.4";
flake = false;
};
cabal-36 = {
url = "github:haskell/cabal/3.6";
flake = false;
};
cardano-shell = {
url = "github:input-output-hk/cardano-shell";
flake = false;
};
"ghc-8.6.5-iohk" = {
type = "github";
owner = "input-output-hk";
repo = "ghc";
ref = "release/8.6.5-iohk";
flake = false;
};
hpc-coveralls = {
url = "github:sevanspowell/hpc-coveralls";
flake = false;
};
old-ghc-nix = {
url = "github:angerman/old-ghc-nix/master";
flake = false;
};
HTTP = {
url = "github:phadej/HTTP";
flake = false;
};
iserv-proxy = {
url = "github:stable-haskell/iserv-proxy?ref=iserv-syms";
flake = false;
};
};
outputs =
{ self
, nixpkgs
, nixpkgs-unstable
, flake-compat
, ...
}@inputs:
let
callFlake = import flake-compat;
ifdLevel = 3;
runningHydraEvalTest = false;
defaultCompiler = "ghc928";
config = import ./config.nix;
inherit (nixpkgs) lib;
traceNames = prefix: builtins.mapAttrs (n: v:
if builtins.isAttrs v
then if v ? type && v.type == "derivation"
then builtins.trace (prefix + n) v
else traceNames (prefix + n + ".") v
else v);
traceHydraJobs = x: x // { inherit (traceNames "" x) hydraJobs; };
# systems supported by haskell.nix
systems = [
"x86_64-linux"
] ++ (if runningHydraEvalTest then [ ] else [
"x86_64-darwin"
"aarch64-darwin"
]);
nixpkgsArgs = {
inherit config;
overlays = [ self.overlay ];
};
forEachSystem = lib.genAttrs systems;
forEachSystemPkgs = f: forEachSystem (system: f self.legacyPackages.${system});
inherit
(import ./ci-lib.nix { inherit lib; })
stripAttrsForHydra
filterDerivations;
flake = {
inherit config;
overlay = self.overlays.combined;
overlays = import ./overlays { sources = inputs; };
internal = {
nixpkgsArgs = {
inherit config;
overlays = [ self.overlay ];
};
sources = inputs;
overlaysOverrideable =
lib.warn
"Using this attribute is deprecated. Import ${./overlays} directly or use the flake overlays output with override-inut."
(import ./overlays);
# Compatibility with old default.nix
compat =
lib.warn
"Using this attribute is deprecated. You can pass the same arguments to ${./default.nix} instead"
(import ./default.nix);
};
legacyPackages = forEachSystem (system:
import nixpkgs {
inherit config;
overlays = [ self.overlay ];
localSystem = { inherit system; };
});
legacyPackagesUnstable = forEachSystem (system:
import nixpkgs-unstable {
inherit config;
overlays = [ self.overlay ];
localSystem = { inherit system; };
});
# Exposed so CI can check that `allow-import-from-derivation=false` works
# for core of haskell.nix E.g. this should always work:
# nix build .#roots.x86_64-linux --accept-flake-config --option allow-import-from-derivation false
roots = forEachSystem (system:
self.legacyPackagesUnstable.${system}.haskell-nix.roots defaultCompiler);
# Note: `nix flake check` evaluates outputs for all platforms, and haskell.nix
# uses IFD heavily, you have to have the ability to build for all platforms
# supported by haskell.nix, e.g. with remote builders, in order to check this flake.
# If you want to run the tests for just your platform, run `./test/tests.sh` or
# `nix-build -A checks.$PLATFORM`
checks = forEachSystemPkgs (pkgs:
builtins.listToAttrs (
map
(pkg: { name = pkg.name; value = pkg; })
(lib.collect
lib.isDerivation
(import ./test {
haskellNix.sources = inputs;
haskellNix.nixpkgsArgs = nixpkgsArgs;
compiler-nix-name = defaultCompiler;
inherit pkgs;
})
)
)
);
# NOTE: these are the hix cli utilities, which is a separate thing from
# the hix.nix overlays (which extends haskell.nix with hixProject).
packages = forEachSystemPkgs (pkgs:
(import ./hix/default.nix { inherit pkgs; }).apps
);
apps = forEachSystemPkgs (pkgs:
builtins.mapAttrs
(name: exe: {
type = "app";
program = exe + "/bin/${name}";
})
pkgs.haskell-nix.nix-tools-unchecked.exes
);
allJobs = forEachSystem (system:
stripAttrsForHydra (filterDerivations (
# This is awkward.
import ./ci.nix {
inherit ifdLevel system;
haskellNix = self;
}
)));
requiredJobs = forEachSystem (system:
let
inherit (self.legacyPackages.${system}) releaseTools;
in
lib.concatMapAttrs
(nixpkgsVer:
lib.concatMapAttrs (compiler-nix-name:
lib.concatMapAttrs (crossPlatform: ghcJobs:
let
name = "required-${nixpkgsVer}-${compiler-nix-name}-${crossPlatform}";
value = releaseTools.aggregate {
name = "haskell.nix-${nixpkgsVer}-${compiler-nix-name}-${crossPlatform}";
meta.description = "All ${nixpkgsVer} ${compiler-nix-name} ${crossPlatform} jobs";
constituents = lib.collect lib.isDerivation ghcJobs;
};
in
lib.optionalAttrs
(crossPlatform != "recurseForDerivations" && crossPlatform != "meta")
{ ${name} = value; })
)
)
self.allJobs.${system}
);
hydraJobs = forEachSystem (system:
let
# Include hydraJobs from nix-tools subflake.
# NOTE: These derivations do not depend on the haskell.nix in ./. but
# on the version of haskell.nix locked in the subflake. They are
# evaluated within their own flake and independently of anything
# else. Here we only expose them in the main flake.
nix-tools-hydraJobs =
let
cf = callFlake {
inherit system;
pkgs = self.legacyPackages.${system};
src = ./nix-tools;
};
in
cf.defaultNix.hydraJobs;
in
self.allJobs.${system}
// lib.optionalAttrs (ifdLevel > 2)
{ nix-tools = nix-tools-hydraJobs.${system} or { }; }
);
devShells = forEachSystemPkgs (pkgs:
let
mkHaskellNixShell = compiler-nix-name:
pkgs.mkShell {
buildInputs = [
pkgs.nixVersions.latest
pkgs.haskell-nix.cabal-install.${compiler-nix-name}
pkgs.haskell-nix.compiler.${compiler-nix-name}
];
};
shells = lib.genAttrs (
# Exclude old versions of GHC to speed up `nix flake check`
lib.attrNames (
lib.removeAttrs pkgs.haskell-nix.compiler
([ "ghc844" ] ++
[ "ghc861" "ghc862" "ghc863" "ghc864" ] ++
[ "ghc881" "ghc882" "ghc883" ] ++
[ "ghc8101" "ghc8102" "ghc8103" "ghc8104" "ghc810420210212" "ghc8105" "ghc8106" ] ++
[ "ghc901" ] ++ [ "ghc921" "ghc922" "ghc923" ])
))
mkHaskellNixShell;
in
shells // { default = shells.${defaultCompiler}; });
};
in
traceHydraJobs (lib.recursiveUpdate flake (lib.optionalAttrs (ifdLevel > 2)
(
let pkgs = nixpkgs.legacyPackages."x86_64-linux"; in
{
hydraJobs.nix-tools = pkgs.releaseTools.aggregate {
name = "nix-tools";
constituents = (if runningHydraEvalTest then [ ] else [
"aarch64-darwin.nix-tools.static.zipped.nix-tools-static"
"x86_64-darwin.nix-tools.static.zipped.nix-tools-static"
"aarch64-darwin.nix-tools.static.zipped.nix-tools-static-no-ifd"
"x86_64-darwin.nix-tools.static.zipped.nix-tools-static-no-ifd"
]) ++ [
"x86_64-linux.nix-tools.static.zipped.nix-tools-static"
"x86_64-linux.nix-tools.static.zipped.nix-tools-static-arm64"
"x86_64-linux.nix-tools.static.zipped.nix-tools-static-no-ifd"
"x86_64-linux.nix-tools.static.zipped.nix-tools-static-arm64-no-ifd"
(pkgs.writeText "gitrev" (self.rev or "0000000000000000000000000000000000000000"))
];
};
}
)));
# --- Flake Local Nix Configuration ----------------------------
nixConfig = {
# This sets the flake to use the IOG nix cache.
# Nix should ask for permission before using it,
# but remove it here if you do not want it to.
extra-substituters = [ "https://cache.iog.io" ];
extra-trusted-public-keys = [ "hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ=" ];
allow-import-from-derivation = "true";
};
}