forked from input-output-hk/haskell.nix
-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
230 lines (215 loc) · 8.82 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
{
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-unstable = { url = "github:NixOS/nixpkgs/nixpkgs-unstable"; };
flake-compat = { url = "github:input-output-hk/flake-compat/hkm/gitlab-fix"; flake = false; };
flake-utils = { url = "github:numtide/flake-utils"; };
tullia = {
url = "github:input-output-hk/tullia";
inputs.nixpkgs.follows = "nixpkgs";
};
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 = {
type = "git";
url = "https://gitlab.haskell.org/hamishmack/iserv-proxy.git";
ref = "hkm/remote-iserv";
flake = false;
};
};
outputs = { self, nixpkgs, nixpkgs-unstable, nixpkgs-2105, nixpkgs-2111, nixpkgs-2205, nixpkgs-2211, flake-utils, tullia, ... }@inputs:
let compiler = "ghc926";
config = import ./config.nix;
traceNames = prefix: builtins.mapAttrs (n: v:
if builtins.isAttrs v
then if v ? type && v.type == "derivation"
then __trace (prefix + n) v
else traceNames (prefix + n + ".") v
else v);
traceHydraJobs = x: x // { inherit (traceNames "" x) hydraJobs; };
in traceHydraJobs ({
inherit config;
overlay = self.overlays.combined;
overlays = import ./overlays { sources = inputs; };
internal = rec {
nixpkgsArgs = {
inherit config;
overlays = [ self.overlay ];
};
sources = inputs;
overlaysOverrideable = import ./overlays;
# Compatibility with old default.nix
compat = { checkMaterialization ?
false # Allows us to easily switch on materialization checking
, system, sourcesOverride ? { }, ... }@args: rec {
sources = inputs // sourcesOverride;
allOverlays = import ./overlays (args // { inherit sources; });
inherit config;
# We are overriding 'overlays' and 'nixpkgsArgs' from the
# flake outputs so that we can incorporate the args passed
# to the compat layer (e.g. sourcesOverride).
overlays = [ allOverlays.combined ]
++ (if checkMaterialization == true then
[
(final: prev: {
haskell-nix = prev.haskell-nix // {
checkMaterialization = true;
};
})
]
else
[ ]);
nixpkgsArgs = {
inherit config overlays;
};
pkgs = import nixpkgs
(nixpkgsArgs // { localSystem = { inherit system; }; });
pkgs-2105 = import nixpkgs-2105
(nixpkgsArgs // { localSystem = { inherit system; }; });
pkgs-2111 = import nixpkgs-2111
(nixpkgsArgs // { localSystem = { inherit system; }; });
pkgs-2205 = import nixpkgs-2205
(nixpkgsArgs // { localSystem = { inherit system; }; });
pkgs-2211 = import nixpkgs-2211
(nixpkgsArgs // { localSystem = { inherit system; }; });
pkgs-unstable = import nixpkgs-unstable
(nixpkgsArgs // { localSystem = { inherit system; }; });
hix = import ./hix/default.nix { inherit pkgs; };
};
};
# 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`
} // flake-utils.lib.eachSystem [ "x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin" ] (system: rec {
legacyPackages = (self.internal.compat { inherit system; }).pkgs;
legacyPackagesUnstable = (self.internal.compat { inherit system; }).pkgs-unstable;
# FIXME: Currently `nix flake check` requires `--impure` because coverage-golden
# (and maybe other tests) import projects that use builtins.currentSystem
checks = builtins.listToAttrs (map (pkg: {
name = pkg.name;
value = pkg;
}) (nixpkgs.lib.collect nixpkgs.lib.isDerivation (import ./test rec {
haskellNix = self.internal.compat { inherit system; };
compiler-nix-name = compiler;
pkgs = haskellNix.pkgs;
})));
# Exposed so that buildkite can check that `allow-import-from-derivation=false` works for core of haskell.nix
roots = legacyPackagesUnstable.haskell-nix.roots compiler;
packages = ((self.internal.compat { inherit system; }).hix).apps;
allJobs =
let
inherit (import ./ci-lib.nix { pkgs = legacyPackagesUnstable; }) stripAttrsForHydra filterDerivations;
ci = import ./ci.nix { inherit (self.internal) compat; inherit system; };
in stripAttrsForHydra (filterDerivations ci);
ciJobs =
let
inherit (legacyPackages) lib;
names = x: lib.filter (n: n != "recurseForDerivations" && n != "meta")
(builtins.attrNames x);
requiredJobs =
builtins.listToAttrs (
lib.concatMap (nixpkgsVer:
let nixpkgsJobs = allJobs.${nixpkgsVer};
in lib.concatMap (compiler-nix-name:
let ghcJobs = nixpkgsJobs.${compiler-nix-name};
in (
builtins.map (crossPlatform: {
name = "required-${nixpkgsVer}-${compiler-nix-name}-${crossPlatform}";
value = legacyPackages.releaseTools.aggregate {
name = "haskell.nix-${nixpkgsVer}-${compiler-nix-name}-${crossPlatform}";
meta.description = "All ${nixpkgsVer} ${compiler-nix-name} ${crossPlatform} jobs";
constituents = lib.collect (d: lib.isDerivation d) ghcJobs.${crossPlatform};
};
}) (names ghcJobs))
) (names nixpkgsJobs)
) (names allJobs));
in lib.optionalAttrs (system == "x86_64-linux") {
latest = allJobs.unstable.ghc8107.native or {};
} // requiredJobs;
hydraJobs = ciJobs;
devShells = with self.legacyPackages.${system}; {
default =
mkShell {
buildInputs = [
nixUnstable
cabal-install
haskell-nix.compiler.${compiler}
];
};
} // __mapAttrs (compiler-nix-name: compiler:
mkShell {
buildInputs = [
compiler
haskell-nix.cabal-install.${compiler-nix-name}
];
}
) (
# Exclude old versions of GHC to speed up `nix flake check`
builtins.removeAttrs haskell-nix.compiler
[ "ghc844"
"ghc861" "ghc862" "ghc863" "ghc864"
"ghc881" "ghc882" "ghc883"
"ghc8101" "ghc8102" "ghc8103" "ghc8104" "ghc8105" "ghc8106" "ghc810420210212"
"ghc901"
"ghc921" "ghc922" "ghc923"]);
} // tullia.fromSimple system (import ./tullia.nix)));
# --- 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";
};
}