on skeleton-uses-prerender help sign in
obelisk/jobsets.nix
66 lines 1.8 kB history raw
1{ prs }:
3let
4 self = import ./. {};
5 pkgs = self.nixpkgs;
6 mkFetchGithub = value: {
7 inherit value;
8 type = "git";
9 emailresponsible = false;
10 };
11in
12with pkgs.lib;
13let
14 defaults = jobs: {
15 inherit (jobs) description;
16 enabled = 1;
17 hidden = false;
18 keepnr = 10;
19 schedulingshares = 100;
20 checkinterval = 120;
21 enableemail = false;
22 emailoverride = "";
23 nixexprinput = "obelisk";
24 nixexprpath = "release.nix";
25 inputs = jobs.inputs // {
26 nixpkgs = {
27 type = "git";
28 value = "https://github.com/NixOS/nixpkgs-channels nixos-unstable";
29 emailresponsible = false;
30 };
31 };
32 };
33 branchJobset = branch: defaults {
34 description = "obelisk-${branch}";
35 inputs = {
36 obelisk = {
37 value = "https://github.com/obsidiansystems/obelisk ${branch}";
38 type = "git";
39 emailresponsible = false;
40 };
41 };
42 };
43 makePr = num: info: {
44 name = "obelisk-pr-${num}";
45 value = defaults {
46 description = "#${num}: ${info.title}";
47 inputs = {
48 obelisk = {
49 #NOTE: This should really use "pull/${num}/merge"; however, GitHub's
50 #status checks only operate on PR heads. This creates a race
51 #condition, which can currently only be solved by requiring PRs to be
52 #up to date before they're merged. See
53 #https://github.com/isaacs/github/issues/1002
54 value = "https://github.com/obsidiansystems/obelisk pull/${num}/head";
55 type = "git";
56 emailresponsible = false;
57 };
58 };
59 };
60 };
61 processedPrs = mapAttrs' makePr (builtins.fromJSON (builtins.readFile prs));
62 jobsetsAttrs = processedPrs //
63 genAttrs ["master"] branchJobset;
64in {
65 jobsets = pkgs.writeText "spec.json" (builtins.toJSON jobsetsAttrs);