ops/nixos/lib: enable 'switch-prebuilt latest' for getting latest closure

This commit is contained in:
Luke Granger-Brown 2021-04-04 18:25:01 +01:00
parent dddbb9828d
commit 33cfba2e2f
2 changed files with 15 additions and 0 deletions

View 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"

View file

@ -10,6 +10,10 @@ pkgs.writeShellScriptBin "switch-prebuilt" ''
export AWS_SECRET_ACCESS_KEY="${depot.ops.secrets.nixCache.AWS_SECRET_ACCESS_KEY}"
system="''${1}"
if [[ "$system" == "latest" ]]; then
system="$(${./latest_system_closure.sh})"
fi
if [[ ! -e "$system" ]]; then
# We should be a trusted-user.
nix copy -v --from 's3://lukegb-nix-cache?endpoint=storage.googleapis.com' --no-check-sigs "$system"