|
9 | 9 | let |
10 | 10 | inherit (lib) |
11 | 11 | any |
12 | | - attrValues |
13 | 12 | concatStringsSep |
14 | 13 | escapeShellArg |
15 | 14 | hasInfix |
|
20 | 19 | mkIf |
21 | 20 | mkOption |
22 | 21 | mkPackageOption |
23 | | - mkRenamedOptionModule |
24 | 22 | nameValuePair |
25 | 23 | optionalAttrs |
26 | 24 | optionals |
|
36 | 34 |
|
37 | 35 | settingsFormat = pkgs.formats.yaml { }; |
38 | 36 |
|
39 | | - # Empty label strings result in upstream default labels, which require docker. |
40 | | - hasDockerScheme = |
41 | | - instance: instance.labels == [ ] || any (label: hasInfix ":docker:" label) instance.labels; |
42 | | - wantsContainerRuntime = any hasDockerScheme (attrValues cfg.instances); |
| 37 | + instanceLabels = |
| 38 | + instance: |
| 39 | + instance.labels |
| 40 | + ++ lib.concatMap (connection: connection.labels or [ ]) ( |
| 41 | + lib.attrValues (instance.settings.server.connections or { }) |
| 42 | + ); |
43 | 43 |
|
44 | | - hasHostScheme = instance: any (label: hasSuffix ":host" label) instance.labels; |
| 44 | + hasDockerScheme = labels: any (label: hasInfix ":docker:" label) labels; |
| 45 | + hasHostScheme = labels: any (label: hasSuffix ":host" label) labels; |
| 46 | + |
| 47 | + wantsContainerRuntime = any (instance: hasDockerScheme (instanceLabels instance)) ( |
| 48 | + lib.attrValues cfg.instances |
| 49 | + ); |
45 | 50 |
|
46 | 51 | hasDocker = config.virtualisation.docker.enable; |
47 | 52 | hasPodman = config.virtualisation.podman.enable; |
|
110 | 115 | }; |
111 | 116 |
|
112 | 117 | labels = mkOption { |
113 | | - type = nullOr (listOf str); |
| 118 | + type = listOf str; |
| 119 | + default = [ ]; |
114 | 120 | example = literalExpression '' |
115 | 121 | [ |
116 | 122 | # provide a debian base with nodejs for actions |
|
202 | 208 | mkRunnerInstance = |
203 | 209 | _: instance: |
204 | 210 | let |
| 211 | + allLabels = instanceLabels instance; |
205 | 212 | escapedName = escapeSystemdPath instance.name; |
206 | | - wantsContainer = hasDockerScheme instance; |
207 | | - wantsHost = hasHostScheme instance; |
| 213 | + wantsContainer = hasDockerScheme allLabels; |
| 214 | + wantsHost = hasHostScheme allLabels; |
208 | 215 | wantsDocker = wantsContainer && hasDocker; |
209 | 216 | wantsPodman = wantsContainer && hasPodman; |
210 | 217 | configFile = settingsFormat.generate "forgejo-runner-${escapedName}.yaml" instance.settings; |
|
0 commit comments