ops/nixos/lib: enable 'switch-prebuilt latest' for getting latest closure
This commit is contained in:
parent
dddbb9828d
commit
33cfba2e2f
2 changed files with 15 additions and 0 deletions
11
ops/nixos/lib/latest_system_closure.sh
Executable file
11
ops/nixos/lib/latest_system_closure.sh
Executable file
|
@ -0,0 +1,11 @@
|
||||||
|
#!/usr/bin/env nix-shell
|
||||||
|
#!nix-shell -i bash -p bash jq curl unzip
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
tmpdir="$(mktemp -d)"
|
||||||
|
trap '{ rm -rf -- "$tmpdir"; }' EXIT
|
||||||
|
|
||||||
|
curl -so "$tmpdir/archive.zip" 'https://hg.lukegb.com/api/v4/projects/lukegb%2Fdepot/jobs/artifacts/branch%2Fdefault/download?job=nixCache'
|
||||||
|
unzip -d "$tmpdir" -q -o "$tmpdir/archive.zip"
|
||||||
|
jq -r ".$(hostname)" "$tmpdir/systems.json"
|
|
@ -10,6 +10,10 @@ pkgs.writeShellScriptBin "switch-prebuilt" ''
|
||||||
export AWS_SECRET_ACCESS_KEY="${depot.ops.secrets.nixCache.AWS_SECRET_ACCESS_KEY}"
|
export AWS_SECRET_ACCESS_KEY="${depot.ops.secrets.nixCache.AWS_SECRET_ACCESS_KEY}"
|
||||||
system="''${1}"
|
system="''${1}"
|
||||||
|
|
||||||
|
if [[ "$system" == "latest" ]]; then
|
||||||
|
system="$(${./latest_system_closure.sh})"
|
||||||
|
fi
|
||||||
|
|
||||||
if [[ ! -e "$system" ]]; then
|
if [[ ! -e "$system" ]]; then
|
||||||
# We should be a trusted-user.
|
# We should be a trusted-user.
|
||||||
nix copy -v --from 's3://lukegb-nix-cache?endpoint=storage.googleapis.com' --no-check-sigs "$system"
|
nix copy -v --from 's3://lukegb-nix-cache?endpoint=storage.googleapis.com' --no-check-sigs "$system"
|
||||||
|
|
Loading…
Reference in a new issue