|
7 | 7 | let |
8 | 8 | cfg = config.services.hydra-queue-builder-dev; |
9 | 9 | user = config.users.users.hydra-queue-builder; |
| 10 | + |
| 11 | + format = pkgs.formats.toml { }; |
10 | 12 | in |
11 | 13 | { |
12 | 14 | options = { |
|
18 | 20 | type = lib.types.singleLineStr; |
19 | 21 | }; |
20 | 22 |
|
21 | | - pingInterval = lib.mkOption { |
22 | | - description = "Interval in which pings are send to the runner"; |
23 | | - type = lib.types.ints.positive; |
24 | | - default = 10; |
25 | | - }; |
| 23 | + settings = lib.mkOption { |
| 24 | + description = "Builder settings written to the TOML config file"; |
| 25 | + type = lib.types.submodule { |
| 26 | + options = { |
| 27 | + pingInterval = lib.mkOption { |
| 28 | + description = "Interval in which pings are send to the runner"; |
| 29 | + type = lib.types.ints.positive; |
| 30 | + default = 10; |
| 31 | + }; |
26 | 32 |
|
27 | | - speedFactor = lib.mkOption { |
28 | | - description = "Additional Speed factor for this machine"; |
29 | | - type = lib.types.oneOf [ |
30 | | - lib.types.ints.positive |
31 | | - lib.types.float |
32 | | - ]; |
33 | | - default = 1; |
34 | | - }; |
| 33 | + speedFactor = lib.mkOption { |
| 34 | + description = "Additional Speed factor for this machine"; |
| 35 | + type = lib.types.oneOf [ |
| 36 | + lib.types.ints.positive |
| 37 | + lib.types.float |
| 38 | + ]; |
| 39 | + default = 1; |
| 40 | + }; |
35 | 41 |
|
36 | | - maxJobs = lib.mkOption { |
37 | | - description = "Maximum allowed of jobs. This only is used if the queue runner uses this metrics for determining free machines."; |
38 | | - type = lib.types.ints.positive; |
39 | | - default = 4; |
40 | | - }; |
| 42 | + maxJobs = lib.mkOption { |
| 43 | + description = "Maximum allowed of jobs. This only is used if the queue runner uses this metrics for determining free machines."; |
| 44 | + type = lib.types.ints.positive; |
| 45 | + default = 4; |
| 46 | + }; |
41 | 47 |
|
42 | | - buildDirAvailThreshold = lib.mkOption { |
43 | | - description = "Threshold in percent for nix build dir before jobs are no longer scheduled on the machine"; |
44 | | - type = lib.types.float; |
45 | | - default = 10.0; |
46 | | - }; |
| 48 | + buildDirAvailThreshold = lib.mkOption { |
| 49 | + description = "Threshold in percent for nix build dir before jobs are no longer scheduled on the machine"; |
| 50 | + type = lib.types.float; |
| 51 | + default = 10.0; |
| 52 | + }; |
47 | 53 |
|
48 | | - storeAvailThreshold = lib.mkOption { |
49 | | - description = "Threshold in percent for /nix/store before jobs are no longer scheduled on the machine"; |
50 | | - type = lib.types.float; |
51 | | - default = 10.0; |
52 | | - }; |
| 54 | + storeAvailThreshold = lib.mkOption { |
| 55 | + description = "Threshold in percent for /nix/store before jobs are no longer scheduled on the machine"; |
| 56 | + type = lib.types.float; |
| 57 | + default = 10.0; |
| 58 | + }; |
53 | 59 |
|
54 | | - load1Threshold = lib.mkOption { |
55 | | - description = "Maximum Load1 threshold before we stop scheduling jobs on that node. Only used if PSI is not available."; |
56 | | - type = lib.types.float; |
57 | | - default = 8.0; |
58 | | - }; |
| 60 | + load1Threshold = lib.mkOption { |
| 61 | + description = "Maximum Load1 threshold before we stop scheduling jobs on that node. Only used if PSI is not available."; |
| 62 | + type = lib.types.float; |
| 63 | + default = 8.0; |
| 64 | + }; |
59 | 65 |
|
60 | | - cpuPsiThreshold = lib.mkOption { |
61 | | - description = "Maximum CPU PSI in the last 10s before we stop scheduling jobs on that node"; |
62 | | - type = lib.types.float; |
63 | | - default = 75.0; |
64 | | - }; |
| 66 | + cpuPsiThreshold = lib.mkOption { |
| 67 | + description = "Maximum CPU PSI in the last 10s before we stop scheduling jobs on that node"; |
| 68 | + type = lib.types.float; |
| 69 | + default = 75.0; |
| 70 | + }; |
65 | 71 |
|
66 | | - memPsiThreshold = lib.mkOption { |
67 | | - description = "Maximum Memory PSI in the last 10s before we stop scheduling jobs on that node"; |
68 | | - type = lib.types.float; |
69 | | - default = 80.0; |
70 | | - }; |
| 72 | + memPsiThreshold = lib.mkOption { |
| 73 | + description = "Maximum Memory PSI in the last 10s before we stop scheduling jobs on that node"; |
| 74 | + type = lib.types.float; |
| 75 | + default = 80.0; |
| 76 | + }; |
71 | 77 |
|
72 | | - ioPsiThreshold = lib.mkOption { |
73 | | - description = "Maximum IO PSI in the last 10s before we stop scheduling jobs on that node. If null then this pressure check is disabled."; |
74 | | - type = lib.types.nullOr lib.types.float; |
75 | | - default = null; |
76 | | - }; |
| 78 | + ioPsiThreshold = lib.mkOption { |
| 79 | + description = "Maximum IO PSI in the last 10s before we stop scheduling jobs on that node. If null then this pressure check is disabled."; |
| 80 | + type = lib.types.nullOr lib.types.float; |
| 81 | + default = null; |
| 82 | + }; |
77 | 83 |
|
78 | | - systems = lib.mkOption { |
79 | | - description = "List of supported systems. If none are passed, system and extra-platforms are read from nix."; |
80 | | - type = lib.types.listOf lib.types.singleLineStr; |
81 | | - default = [ ]; |
82 | | - }; |
| 84 | + systems = lib.mkOption { |
| 85 | + description = "List of supported systems. If null, system and extra-platforms are read from nix; an empty list means none."; |
| 86 | + type = lib.types.nullOr (lib.types.listOf lib.types.singleLineStr); |
| 87 | + default = null; |
| 88 | + }; |
83 | 89 |
|
84 | | - supportedFeatures = lib.mkOption { |
85 | | - description = "Pass supported features to the builder. If none are passed, system features will be used."; |
86 | | - type = lib.types.listOf lib.types.singleLineStr; |
87 | | - default = [ ]; |
88 | | - }; |
| 90 | + supportedFeatures = lib.mkOption { |
| 91 | + description = "Supported features for the builder. If null, system features are read from nix; an empty list means none."; |
| 92 | + type = lib.types.nullOr (lib.types.listOf lib.types.singleLineStr); |
| 93 | + default = null; |
| 94 | + }; |
89 | 95 |
|
90 | | - mandatoryFeatures = lib.mkOption { |
91 | | - description = "Pass mandatory features to the builder."; |
92 | | - type = lib.types.listOf lib.types.singleLineStr; |
93 | | - default = [ ]; |
94 | | - }; |
| 96 | + mandatoryFeatures = lib.mkOption { |
| 97 | + description = "Mandatory features for the builder."; |
| 98 | + type = lib.types.listOf lib.types.singleLineStr; |
| 99 | + default = [ ]; |
| 100 | + }; |
95 | 101 |
|
96 | | - useSubstitutes = lib.mkOption { |
97 | | - description = "Use substitution for paths"; |
98 | | - type = lib.types.bool; |
99 | | - default = true; |
| 102 | + useSubstitutes = lib.mkOption { |
| 103 | + description = "Use substitution for paths"; |
| 104 | + type = lib.types.bool; |
| 105 | + default = true; |
| 106 | + }; |
| 107 | + }; |
| 108 | + }; |
| 109 | + default = { }; |
100 | 110 | }; |
101 | 111 |
|
102 | 112 | authorizationFile = lib.mkOption { |
|
154 | 164 | "${cfg.package}/bin/hydra-builder" |
155 | 165 | "--gateway-endpoint" |
156 | 166 | cfg.queueRunnerAddr |
157 | | - "--ping-interval" |
158 | | - cfg.pingInterval |
159 | | - "--speed-factor" |
160 | | - cfg.speedFactor |
161 | | - "--max-jobs" |
162 | | - cfg.maxJobs |
163 | | - "--build-dir-avail-threshold" |
164 | | - cfg.buildDirAvailThreshold |
165 | | - "--store-avail-threshold" |
166 | | - cfg.storeAvailThreshold |
167 | | - "--load1-threshold" |
168 | | - cfg.load1Threshold |
169 | | - "--cpu-psi-threshold" |
170 | | - cfg.cpuPsiThreshold |
171 | | - "--mem-psi-threshold" |
172 | | - cfg.memPsiThreshold |
173 | | - ] |
174 | | - ++ lib.optionals (cfg.ioPsiThreshold != null) [ |
175 | | - "--io-psi-threshold" |
176 | | - cfg.ioPsiThreshold |
177 | | - ] |
178 | | - ++ (builtins.concatMap (v: [ |
179 | | - "--systems" |
180 | | - v |
181 | | - ]) cfg.systems) |
182 | | - ++ (builtins.concatMap (v: [ |
183 | | - "--supported-features" |
184 | | - v |
185 | | - ]) cfg.supportedFeatures) |
186 | | - ++ (builtins.concatMap (v: [ |
187 | | - "--mandatory-features" |
188 | | - v |
189 | | - ]) cfg.mandatoryFeatures) |
190 | | - ++ lib.optionals (cfg.useSubstitutes != null) [ |
191 | | - "--use-substitutes" |
| 167 | + "--config-path" |
| 168 | + "/etc/hydra/builder.toml" |
192 | 169 | ] |
193 | 170 | ++ lib.optionals (cfg.authorizationFile != null) [ |
194 | 171 | "--authorization-file" |
|
227 | 204 | WorkingDirectory = user.home; |
228 | 205 | }; |
229 | 206 | }; |
| 207 | + |
| 208 | + environment.etc."hydra/builder.toml".source = format.generate "builder.toml" ( |
| 209 | + lib.filterAttrsRecursive (_: v: v != null) cfg.settings |
| 210 | + ); |
| 211 | + |
230 | 212 | users = { |
231 | 213 | users.hydra-queue-builder = { |
232 | 214 | uid = lib.mkDefault 535; |
|
0 commit comments