scripts/deploy: add more logging
This commit is contained in:
parent
b5fc8cfd4e
commit
f477370e4c
|
@ -15,6 +15,10 @@ usage() {
|
|||
exit 1
|
||||
}
|
||||
|
||||
info() {
|
||||
echo "[deploy]" "$@"
|
||||
}
|
||||
|
||||
action=switch
|
||||
host=$(hostname)
|
||||
variant=
|
||||
|
@ -69,8 +73,10 @@ deployOneHost() {
|
|||
local host="$1"
|
||||
local variant="$2"
|
||||
|
||||
info "building $host$variant ..."
|
||||
nix-build -A "hosts.$host$variant.toplevel" --out-link "./build/result-$host$variant" "${nixArgs[@]}" || return 1
|
||||
storePath="$(readlink ./build/result-$host$variant)"
|
||||
info "build $host$variant -> $storePath"
|
||||
|
||||
# mimic `nixos-rebuild --target-host`, in effect:
|
||||
# - nix-copy-closure ...
|
||||
|
@ -83,9 +89,10 @@ deployOneHost() {
|
|||
|
||||
if [ -n "$host" ]; 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"
|
||||
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
|
||||
# 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.
|
||||
|
@ -94,6 +101,7 @@ deployOneHost() {
|
|||
fi
|
||||
|
||||
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 "$storePath/bin/switch-to-configuration" "$action" || return 1
|
||||
fi
|
||||
|
|
Loading…
Reference in New Issue
Block a user