forked from colin/nix-files
scripts/deploy: add more logging
This commit is contained in:
parent
b5fc8cfd4e
commit
f477370e4c
|
@ -15,6 +15,10 @@ usage() {
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
info() {
|
||||||
|
echo "[deploy]" "$@"
|
||||||
|
}
|
||||||
|
|
||||||
action=switch
|
action=switch
|
||||||
host=$(hostname)
|
host=$(hostname)
|
||||||
variant=
|
variant=
|
||||||
|
@ -69,8 +73,10 @@ deployOneHost() {
|
||||||
local host="$1"
|
local host="$1"
|
||||||
local variant="$2"
|
local variant="$2"
|
||||||
|
|
||||||
|
info "building $host$variant ..."
|
||||||
nix-build -A "hosts.$host$variant.toplevel" --out-link "./build/result-$host$variant" "${nixArgs[@]}" || return 1
|
nix-build -A "hosts.$host$variant.toplevel" --out-link "./build/result-$host$variant" "${nixArgs[@]}" || return 1
|
||||||
storePath="$(readlink ./build/result-$host$variant)"
|
storePath="$(readlink ./build/result-$host$variant)"
|
||||||
|
info "build $host$variant -> $storePath"
|
||||||
|
|
||||||
# mimic `nixos-rebuild --target-host`, in effect:
|
# mimic `nixos-rebuild --target-host`, in effect:
|
||||||
# - nix-copy-closure ...
|
# - nix-copy-closure ...
|
||||||
|
@ -83,9 +89,10 @@ deployOneHost() {
|
||||||
|
|
||||||
if [ -n "$host" ]; then
|
if [ -n "$host" ]; then
|
||||||
if [ -e /run/secrets/nix_signing_key ]; then
|
if [ -e /run/secrets/nix_signing_key ]; then
|
||||||
|
info "signing store paths ..."
|
||||||
sudo nix store sign -r -k /run/secrets/nix_signing_key "$storePath"
|
sudo nix store sign -r -k /run/secrets/nix_signing_key "$storePath"
|
||||||
else
|
else
|
||||||
echo "not signing store paths: /run/secrets/nix_signing_key does not exist"
|
info "not signing store paths: /run/secrets/nix_signing_key does not exist"
|
||||||
fi
|
fi
|
||||||
# add more `-v` for more verbosity (up to 5).
|
# add more `-v` for more verbosity (up to 5).
|
||||||
# builders-use-substitutes false: optimizes so that the remote machine doesn't try to get paths from its substituters.
|
# builders-use-substitutes false: optimizes so that the remote machine doesn't try to get paths from its substituters.
|
||||||
|
@ -94,6 +101,7 @@ deployOneHost() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -n "$action" ] && [ "$action" != "copy" ]; then
|
if [ -n "$action" ] && [ "$action" != "copy" ]; then
|
||||||
|
info "activating profile... "
|
||||||
runOnTarget sudo nix-env -p /nix/var/nix/profiles/system --set "$storePath" || return 1
|
runOnTarget sudo nix-env -p /nix/var/nix/profiles/system --set "$storePath" || return 1
|
||||||
runOnTarget sudo "$storePath/bin/switch-to-configuration" "$action" || return 1
|
runOnTarget sudo "$storePath/bin/switch-to-configuration" "$action" || return 1
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in New Issue
Block a user