ops/nixos/lib: inline latest_system_closure.sh
I can't be bothered to make it a proper script, and I also don't really want to rely on invoking nix-shell at runtime (I'd rather have all the needed tools in the system closure).
This commit is contained in:
parent
8dab1a04fe
commit
d582d3f352
2 changed files with 7 additions and 13 deletions
|
@ -1,11 +0,0 @@
|
||||||
#!/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"
|
|
|
@ -11,7 +11,12 @@ pkgs.writeShellScriptBin "switch-prebuilt" ''
|
||||||
system="''${1}"
|
system="''${1}"
|
||||||
|
|
||||||
if [[ "$system" == "latest" ]]; then
|
if [[ "$system" == "latest" ]]; then
|
||||||
system="$(${./latest_system_closure.sh})"
|
tmpdir="$(mktemp -d)"
|
||||||
|
trap '{ rm -rf -- "$tmpdir"; }' EXIT
|
||||||
|
|
||||||
|
${pkgs.curl}/bin/curl -so "$tmpdir/archive.zip" 'https://hg.lukegb.com/api/v4/projects/lukegb%2Fdepot/jobs/artifacts/branch%2Fdefault/download?job=nixCache'
|
||||||
|
${pkgs.unzip}/bin/unzip -d "$tmpdir" -q -o "$tmpdir/archive.zip"
|
||||||
|
system="$(${pkgs.jq}/bin/jq -r ".\"$(hostname)\"" "$tmpdir/systems.json")"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ ! -e "$system" ]]; then
|
if [[ ! -e "$system" ]]; then
|
||||||
|
@ -23,7 +28,7 @@ pkgs.writeShellScriptBin "switch-prebuilt" ''
|
||||||
|
|
||||||
# The next phase requires sudo, but it's harmless to run the preceding commands twice.
|
# The next phase requires sudo, but it's harmless to run the preceding commands twice.
|
||||||
if [[ $EUID -ne 0 ]]; then
|
if [[ $EUID -ne 0 ]]; then
|
||||||
exec sudo "$0" "$@"
|
exec sudo "$0" "$system"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
nix-env -p /nix/var/nix/profiles/system --set "$system"
|
nix-env -p /nix/var/nix/profiles/system --set "$system"
|
||||||
|
|
Loading…
Reference in a new issue