File tree Expand file tree Collapse file tree 1 file changed +20
-4
lines changed
nix/cloud/nomadEnvs/cicero Expand file tree Collapse file tree 1 file changed +20
-4
lines changed Original file line number Diff line number Diff line change 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 : ''
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://builder@10.10.0.${ toString i } x86_64-darwin /secrets/id_buildfarm 4 2 big-parallel - {{index .Data.data "darwin${ toString i } -public" | base64Encode}}'' ;
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
You can’t perform that action at this time.
0 commit comments