Deployment and lifecycle management for Nix
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix: seed-ci uploading

+14 -88
+14 -88
bin/seed-ci
··· 25 25 } 26 26 } 27 27 28 - export def build-targets [--nom: bool = true] { 29 - let targets = $in 30 - 31 - let command = if $nom { "nom" } else { "nix" } 32 - $targets | par-each --threads 2 { |target| 33 - let outPath = try { 34 - let drv = $target | update drvPath ($target.drvPath| str replace --regex ".drv$" ".drv^*") | get drvPath 35 - run-external --redirect-stdout $command build "--no-link" "--fallback" "--keep-going" "--json" $drv | from json | select outputs | flatten | get out 36 - } catch { 37 - null 38 - } 39 - { ...$target, outPath: $outPath } 40 - } 41 - } 42 - 43 - export def eval-targets [] { 44 - let targets = $in 45 - let eval_args = [ 46 - "--gc-roots-dir", "gcroot", 47 - ] ++ (if $env.NIX_EVAL_ARGS? != null { 48 - # dirty, but 🤷 49 - $env.NIX_EVAL_ARGS | split row " " 50 - } else { [ ] }) 51 - 52 - $targets | par-each --threads 4 { |target| 53 - nix-eval-jobs --workers 1 --flake $target $eval_args | lines | each {|l| 54 - $l | from json | select name drvPath 55 - } 56 - } | flatten 57 - } 58 - 59 - export def flake-input-targets [] { 60 - nix flake archive --json | from json | get inputs | transpose | select column0 column1.path | each { |c| 61 - {name: $c.column0, outPath: [$c.column1_path], drvPath: null} 62 - } 63 - } 64 - 65 28 export def load-seeds [] { 66 29 nix eval .#sower --json | from json | transpose type targets | each {|type| $type | update targets ($type.targets | transpose name config) } 67 30 } ··· 105 68 } 106 69 107 70 let result = try { 108 - $buildTarget 109 - # nix build --no-link --fallback --keep-going --json ...$buildTarget | from json 71 + nix build --no-link --fallback --keep-going --json ...$buildTarget | from json 110 72 } catch { 111 73 null 112 74 } ··· 179 141 } | flatten 180 142 } 181 143 182 - export def result-paths [] { 183 - $in | where outPath != null | get outPath | flatten 184 - } 185 - 186 - def main [--v2: bool = true, --attic-upload: bool = true, --attic-use: bool = false, --eval-only, --nom: bool = true, --system: string, ...targets: string ] { 144 + def main [--attic-upload = true, --attic-use = false, --eval-only, --nom = true, --system: string] { 187 145 let attic_url = $env.ATTIC_URL? 188 146 let attic_cache = $env.ATTIC_CACHE? 189 147 let attic_token = $env.ATTIC_KEY? ··· 201 159 } 202 160 } 203 161 204 - if $v2 { 205 - let seeds = load-seeds | filter-configs --system $system 206 - let built_seeds = $seeds | build-configs 162 + let seeds = load-seeds | filter-configs --system $system 163 + let built_seeds = $seeds | build-configs 207 164 208 - if $attic_upload { 209 - $built_seeds | upload-configs --attic-cache $attic_cache 210 - } 165 + if $attic_upload { 166 + $built_seeds | upload-configs --attic-cache $attic_cache 167 + } 211 168 212 - print "🎯 Built seeds" 213 - print ($built_seeds | get-config-outputs) 169 + print "🎯 Built seeds" 170 + print ($built_seeds | get-config-outputs) 214 171 215 - if ($built_seeds | any { |c| $c.targets | any { |t| $t.build == null } }) { 216 - print "💀 Failed targets" 217 - print ($built_seeds | get-config-failures) 218 - exit 1 219 - } else { 220 - print "🥳 Success!" 221 - } 172 + if ($built_seeds | any { |c| $c.targets | any { |t| $t.build == null } }) { 173 + print "💀 Failed targets" 174 + print ($built_seeds | get-config-failures) 175 + exit 1 222 176 } else { 223 - let targets = if $targets != [] { $targets | eval-targets } else { gen-targets --system=$system } 224 - 225 - print "🏛️ Targets" 226 - print $targets 227 - 228 - if $eval_only { 229 - exit 0 230 - } 231 - 232 - if ($targets | is-empty) { 233 - print $"⁉️ (ansi red)!! No targets from env PLUGIN_TARGETS or detected in flake, exiting(ansi reset)" 234 - exit 1 235 - } 236 - 237 - let built_targets = $targets | build-targets --nom=$nom | append (flake-input-targets) 238 - print "🎯 Built targets" 239 - print $built_targets | table -w 200 240 - 241 - if $attic_upload { 242 - $built_targets | result-paths | attic-upload $attic_cache 243 - } 244 - 245 - if ($built_targets | any { |t| $t.outPath == null }) { 246 - print "💀 Failed targets" 247 - print ($built_targets | where outPath == null) 248 - exit 1 249 - } else { 250 - print "🥳 Success!" 251 - } 177 + print "🥳 Success!" 252 178 } 253 179 }