This repository has been archived by the owner on Jun 17, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 41
/
default.nix
343 lines (301 loc) · 10.8 KB
/
default.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
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
############################################################################
# This is the jobset declaration evaluated by Hydra to dynamically
# generate jobsets.
#
# The arguments for this file come from spec.json.
# So also update that file when you add a repo here.
#
# You may also want to check and update the GitHub notifications list
# in modules/hydra-master-main.nix.
#
# Test this file locally with:
# jq . < $(nix-build --no-out-link jobsets/default.nix)
#
# See also the Hydra manual:
# https://github.com/NixOS/hydra/blob/master/doc/manual/declarative-projects.xml
#
############################################################################
{ nixpkgs ? <nixpkgs>
, declInput ? {}
# Paths to JSON files containing PR info fetched from github.
# An example file is ./simple-pr-dummy.json.
, nixopsPrsJSON ? ./simple-pr-dummy.json
, cardanoPrsJSON ? ./simple-pr-dummy.json
, daedalusPrsJSON ? ./simple-pr-dummy.json
, plutusPrsJSON ? ./simple-pr-dummy.json
, logClassifierPrsJSON ? ./simple-pr-dummy.json
, ouroborosNetworkPrsJSON ? ./simple-pr-dummy.json
, iohkMonitoringPrsJSON ? ./simple-pr-dummy.json
, ledgerPrsJSON ? ./simple-pr-dummy.json
, cardanoLedgerSpecsPrsJSON ? ./simple-pr-dummy.json
, walletPrsJSON ? ./simple-pr-dummy.json
, shellPrsJSON ? ./simple-pr-dummy.json
, cardanoNodePrsJSON ? ./simple-pr-dummy.json
, cardanoBasePrsJSON ? ./simple-pr-dummy.json
, iohkNixPrsJSON ? ./simple-pr-dummy.json
, haskellNixPrsJSON ? ./simple-pr-dummy.json
, toolsPrsJSON ? ./simple-pr-dummy.json
}:
let pkgs = import nixpkgs {}; in
with pkgs.lib;
let
##########################################################################
# GitHub repos to make jobsets for.
# These are processed by the mkRepoJobsets function below.
repos = {
cardano-sl = {
description = "Cardano SL";
url = "https://github.com/input-output-hk/cardano-sl.git";
input = "cardano"; # corresponds to argument in cardano-sl/release.nix
branch = "develop";
branches = {
master = "master";
"1-0" = "release/1.0.x";
"1-2" = "release/1.2.0";
"1-3" = "release/1.3.1";
"2-0" = "release/2.0.0";
"3-0-1" = "release/3.0.1";
};
prs = cardanoPrsJSON;
prJobsetModifier = withFasterBuild;
bors = true;
};
daedalus = {
description = "Daedalus Wallet";
url = "https://github.com/input-output-hk/daedalus.git";
branch = "develop";
prs = daedalusPrsJSON;
bors = true;
};
plutus = {
description = "Plutus Language";
url = "https://github.com/input-output-hk/plutus.git";
prs = plutusPrsJSON;
};
log-classifier = {
description = "Log Classifier";
url = "https://github.com/input-output-hk/log-classifier.git";
prs = logClassifierPrsJSON;
bors = true;
};
cardano-ledger = {
description = "Cardano Ledger";
url = "https://github.com/input-output-hk/cardano-ledger.git";
branch = "master";
prs = ledgerPrsJSON;
bors = true;
};
cardano-ledger-specs = {
description = "Cardano Ledger Specs";
url = "https://github.com/input-output-hk/cardano-ledger-specs.git";
branch = "master";
prs = cardanoLedgerSpecsPrsJSON;
};
ouroboros-network = {
description = "Ouroboros Network";
url = "https://github.com/input-output-hk/ouroboros-network.git";
branch = "master";
prs = ouroborosNetworkPrsJSON;
bors = true;
};
iohk-monitoring = {
description = "IOHK Monitoring Framework";
url = "https://github.com/input-output-hk/iohk-monitoring-framework.git";
branch = "develop";
prs = iohkMonitoringPrsJSON;
bors = true;
};
iohk-nix = {
description = "IOHK Common Nix Expressions";
url = "https://github.com/input-output-hk/iohk-nix.git";
branch = "master";
prs = iohkNixPrsJSON;
bors = true;
};
haskell-nix = {
description = "Haskell.nix Build System";
url = "https://github.com/input-output-hk/haskell.nix.git";
branch = "master";
prs = haskellNixPrsJSON;
};
cardano-wallet = {
description = "Cardano Wallet Backend";
url = "https://github.com/input-output-hk/cardano-wallet.git";
branch = "master";
prs = walletPrsJSON;
bors = true;
};
cardano-shell = {
description = "Cardano Shell";
url = "https://github.com/input-output-hk/cardano-shell.git";
branch = "develop";
prs = shellPrsJSON;
bors = true;
};
cardano-node = {
description = "Cardano Node";
url = "https://github.com/input-output-hk/cardano-node.git";
prs = cardanoNodePrsJSON;
bors = true;
};
cardano-base = {
description = "Cardano Base";
url = "https://github.com/input-output-hk/cardano-base.git";
prs = cardanoBasePrsJSON;
bors = true;
};
tools = {
description = "Loony Tools";
url = "https://github.com/input-output-hk/tools.git";
branch = "master";
prs = toolsPrsJSON;
};
};
##########################################################################
# Jobset generation functions
mkFetchGithub = value: {
inherit value;
type = "git";
emailresponsible = false;
};
defaultSettings = {
enabled = 1;
hidden = false;
nixexprinput = "jobsets";
keepnr = 5;
schedulingshares = 42;
checkinterval = 60;
inputs = {
nixpkgs = mkFetchGithub "https://github.com/NixOS/nixpkgs.git ${nixpkgs-src.rev}";
jobsets = mkFetchGithub "${iohkOpsURI} master";
};
enableemail = false;
emailoverride = "";
};
# Adds an arg which disables optimization for cardano-sl builds
withFasterBuild = jobset: jobset // {
inputs = (jobset.inputs or { }) // {
fasterBuild = { type = "boolean"; emailresponsible = false; value = "true"; };
};
};
# Use to put Bors jobs at the front of the build queue.
highPrio = jobset: jobset // {
schedulingshares = 420;
};
# Removes PRs which have any of the labels in ./pr-excluded-labels.nix
exclusionFilter = let
excludedLabels = import ./pr-excluded-labels.nix;
justExcluded = filter (label: (elem label.name excludedLabels));
isEmpty = ls: length ls == 0;
in
filterAttrs (_: prInfo: isEmpty (justExcluded (prInfo.labels or [])));
loadPrsJSON = path: exclusionFilter (builtins.fromJSON (builtins.readFile path));
# Make jobset for a project default build
mkJobset = { name, description, url, input, branch }: let
jobset = defaultSettings // {
nixexprpath = "release.nix";
nixexprinput = input;
inherit description;
inputs = {
"${input}" = mkFetchGithub "${url} ${branch}";
};
};
in
nameValuePair name jobset;
# Make jobsets for extra project branches (e.g. release branches)
mkJobsetBranches = { name, description, url, input }:
mapAttrsToList (suffix: branch:
mkJobset { name = "${name}-${suffix}"; inherit description url input branch; });
# Make a jobset for a GitHub PRs
mkJobsetPR = { name, input, modifier }: num: info: {
name = "${name}-pr-${num}";
value = defaultSettings // modifier {
description = "PR ${num}: ${info.title}";
nixexprinput = input;
nixexprpath = "release.nix";
inputs = {
"${input}" = mkFetchGithub "${info.base.repo.clone_url} pull/${num}/head";
};
};
};
# Load the PRs json and make a jobset for each
mkJobsetPRs = { name, input, modifier, prs }:
mapAttrsToList
(mkJobsetPR { inherit name input modifier; })
(loadPrsJSON prs);
# Add two extra jobsets for the bors staging and trying branches
mkJobsetBors = { name, ... }@args: let
jobset = branch: (mkJobset (args // { inherit branch; })).value;
in [
(nameValuePair "${name}-bors-staging" (highPrio (jobset "bors/staging")))
(nameValuePair "${name}-bors-trying" (jobset "bors/trying"))
];
# Make all the jobsets for a project repo, according to the "repos" spec above.
mkRepoJobsets = let
mkRepo = name: info: let
input = info.input or name;
branch = info.branch or "master";
params = { inherit name input; inherit (info) description url; };
prJobsetModifier = info.prJobsetModifier or (s: s);
in
[ (mkJobset (params // { inherit branch; })) ] ++
(mkJobsetBranches params (info.branches or {})) ++
(mkJobsetPRs { inherit name input; inherit (info) prs; modifier = prJobsetModifier; }) ++
(optionals (info.bors or false) (mkJobsetBors params));
in
rs: listToAttrs (concatLists (mapAttrsToList mkRepo rs));
##########################################################################
# iohk-ops structure is slightly different
iohkOpsURI = "https://github.com/input-output-hk/iohk-ops.git";
nixpkgs-src = builtins.fromJSON (builtins.readFile ./../nixpkgs-src.json);
mkNixops = nixopsBranch: nixpkgsRev: {
nixexprpath = "jobsets/cardano.nix";
description = "IOHK-Ops";
inputs = {
nixpkgs = mkFetchGithub "https://github.com/NixOS/nixpkgs.git ${nixpkgsRev}";
jobsets = mkFetchGithub "${iohkOpsURI} ${nixopsBranch}";
nixops = mkFetchGithub "https://github.com/NixOS/NixOps.git tags/v1.5";
};
};
makeNixopsPR = num: info: {
name = "iohk-ops-pr-${num}";
value = defaultSettings // {
description = "PR ${num}: ${info.title}";
nixexprpath = "jobsets/cardano.nix";
inputs = {
nixpkgs = mkFetchGithub "https://github.com/NixOS/nixpkgs.git ${nixpkgs-src.rev}";
jobsets = mkFetchGithub "${info.base.repo.clone_url} pull/${num}/head";
nixops = mkFetchGithub "https://github.com/NixOS/NixOps.git tags/v1.5";
};
};
};
nixopsPrJobsets = listToAttrs (mapAttrsToList makeNixopsPR (loadPrsJSON nixopsPrsJSON));
##########################################################################
# Jobsets which don't fit into the regular structure
extraJobsets = mapAttrs (name: settings: defaultSettings // settings) ({
# Provides cached build projects for PR builds with -O0
no-opt-cardano-sl = withFasterBuild mainJobsets.cardano-sl;
# iohk-ops (this repo)
iohk-ops = mkNixops "master" nixpkgs-src.rev;
iohk-ops-bors-staging = highPrio (mkNixops "bors-staging" nixpkgs-src.rev);
iohk-ops-bors-trying = mkNixops "bors-trying" nixpkgs-src.rev;
rust-cardano = (mkJobset {
name = "rust-cardano";
input = "rust-cardano";
description = "Cardano Rust Library";
url = "https://github.com/input-output-hk/rust-cardano.git";
branch = "master";
}).value;
} // nixopsPrJobsets);
##########################################################################
# The final jobsets spec as JSON
mainJobsets = mkRepoJobsets repos;
jobsetsAttrs = mainJobsets // extraJobsets;
in {
jobsets = pkgs.runCommand "spec.json" {} ''
cat <<EOF
${builtins.toJSON declInput}
EOF
cp ${pkgs.writeText "spec.json" (builtins.toJSON jobsetsAttrs)} $out
'';
}