Skip to content

Commit 4c5a70f

Browse files
committed
cicero job: append remote nix builders in mac transformer
instead of overwriting the template for ~/.config/nix/nix.conf also fix quoting issue
1 parent 28697a6 commit 4c5a70f

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

nix/cloud/nomadEnvs/cicero/default.nix

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,8 @@
9292
data = let
9393
templates = [
9494
{
95-
# this will be changed to DestPath in the transformer
9695
DestPathInHome = ".ssh/known_hosts";
96+
append = true;
9797

9898
EmbeddedTmpl = let
9999
builder = i: ''
@@ -116,8 +116,8 @@
116116
'';
117117
}
118118
{
119-
# this will be changed to DestPath in the transformer
120119
DestPathInHome = ".config/nix/nix.conf";
120+
append = true;
121121

122122
EmbeddedTmpl = let
123123
builder = i: ''ssh://[email protected].${toString i} x86_64-darwin /secrets/id_buildfarm 4 2 big-parallel - {{index .Data.data "darwin${toString i}-public" | base64Encode}}'';
@@ -135,22 +135,38 @@
135135
in ''
136136
#! /bin/bash
137137
/bin/jq --compact-output \
138-
--argjson templates '{{ base64Decode "${lib.fileContents templatesJsonBase64}" }}' \
138+
--arg templates ${lib.escapeShellArg (lib.fileContents templatesJsonBase64)} \
139139
'
140140
.job.TaskGroups[]?.Tasks[]? |=
141141
.Env.HOME as $home |
142142
if $home == null
143143
then error("`.job.TaskGroups[].Tasks[].Env.HOME` must be set for the darwin-nix-remote-builders transformer")
144144
else .Templates |= (
145145
. + (
146-
$templates |
146+
$templates | @base64d | fromjson |
147147
map(
148148
if has("DestPathInHome")
149149
then del(.DestPathInHome) + {DestPath: ($home + "/" + .DestPathInHome)}
150150
else .
151151
end
152152
)
153153
) |
154+
group_by(.DestPath) |
155+
map(
156+
sort_by(.append) |
157+
if .[length - 1].append | not
158+
then .
159+
else [reduce .[range(1; length)] as $tmpl (
160+
.[0];
161+
if $tmpl | .append | not
162+
then error("Multiple templates that are not meant to be appended have the same destination")
163+
else . + {EmbeddedTmpl: (.EmbeddedTmpl + "\n" + $tmpl.EmbeddedTmpl)}
164+
end
165+
)]
166+
end |
167+
.[] |
168+
del(.append)
169+
) |
154170
unique
155171
)
156172
end

0 commit comments

Comments
 (0)