This repository has been archived by the owner on Apr 28, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
jobsets.nix
73 lines (71 loc) · 2.13 KB
/
jobsets.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
{ nixpkgs ? <nixpkgs>, declInput ? {} }:
let
pkgs = import nixpkgs {};
defaultSettings = {
enabled = "1";
hidden = false;
description = "";
input = "jobs";
path = "default.nix";
keep = 1;
shares = 42;
interval = 300;
inputs = {
jobs = {
type = "git";
value = "git://github.com/hackerspace/base48-hydra-configs";
};
nixpkgs = {
type = "git";
value = "git://github.com/NixOS/nixpkgs";
};
supportedSystems = {
type = "nix";
value = ''[ \"x86_64-linux\" \"armv7l-linux\" ]'';
};
};
mail = false;
mailOverride = "[email protected]";
};
jobsetsAttrs = with pkgs.lib; mapAttrs (name: settings: recursiveUpdate defaultSettings settings) (rec {
# if we decide to add default.nix to base48-hydra-configs
#hydra-jobs-master = {
# keep = 3;
# shares = 420;
#};
nixos-small-master = {
input = "nixpkgs";
path = "nixos/release-small.nix";
};
});
fileContents = with pkgs.lib; ''
cat <<EOF
${builtins.toXML declInput}
EOF
cat > $out <<EOF
{
${concatStringsSep "," (mapAttrsToList (name: settings: ''
"${name}": {
"enabled": ${settings.enabled},
"hidden": ${if settings.hidden then "true" else "false"},
"description": "${settings.description}",
"nixexprinput": "${settings.input}",
"nixexprpath": "${settings.path}",
"checkinterval": ${toString settings.interval},
"schedulingshares": ${toString settings.shares},
"enableemail": ${if settings.mail then "true" else "false"},
"emailoverride": "${settings.mailOverride}",
"keepnr": ${toString settings.keep},
"inputs": {
${concatStringsSep "," (mapAttrsToList (inputName: inputSettings: ''
"${inputName}": { "type": "${inputSettings.type}", "value": "${inputSettings.value}", "emailresponsible": false }
'') settings.inputs)}
}
}
'') jobsetsAttrs)}
}
EOF
'';
in {
jobsets = pkgs.runCommand "spec.json" {} fileContents;
}