forked from c3d2/nix-config
deploy-flake: always use target hostname for safety
This commit is contained in:
parent
4337e4a77e
commit
365757073a
|
@ -26,25 +26,25 @@ while [[ $# -gt 0 ]]; do
|
|||
build_local=true
|
||||
;;
|
||||
*)
|
||||
# strip hostname and user
|
||||
host=$1
|
||||
target=${1//.hq.c3d2.de/}
|
||||
target=${target//.c3d2.de/}
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
if [[ -v build_local ]]; then
|
||||
nix --experimental-features 'nix-command flakes' -Lv build ".#nixosConfigurations.$target.config.system.build.toplevel"
|
||||
hostname=$(ssh root@"$host" hostname)
|
||||
echo "$hostname> nix build"
|
||||
nix --experimental-features 'nix-command flakes' -Lv build ".#nixosConfigurations.$hostname.config.system.build.toplevel"
|
||||
store_path=$(readlink -f result)
|
||||
echo "$hostname> nix copy"
|
||||
nix --experimental-features 'nix-command flakes' copy --to ssh://root@"$host" -v "$store_path"
|
||||
|
||||
echo "$hostname> switch-to-configuration switch"
|
||||
ssh root@"$host" "$store_path/bin/switch-to-configuration" switch
|
||||
else
|
||||
hostname=$(echo "$target" | cut -d . -f 1)
|
||||
rsync -az "$(dirname "$0")" root@"$host":nix-config
|
||||
|
||||
rsync -az "$(dirname "$0")" root@"$target":nix-config
|
||||
|
||||
echo "$hostname> nixos-rebuild switch"
|
||||
exec ssh root@"$target" "nixos-rebuild --flake ./nix-config#`hostname` switch"
|
||||
echo "> nixos-rebuild switch"
|
||||
exec ssh root@"$host" 'nixos-rebuild --flake git+file://`pwd`/nix-config#`hostname` --override-input secrets git+file://`pwd`/nix-config/secrets switch'
|
||||
fi
|
||||
|
|
Loading…
Reference in New Issue