From 365757073ad5cbb14f503001062f984361d60d24 Mon Sep 17 00:00:00 2001 From: Astro Date: Fri, 7 Jan 2022 00:15:43 +0100 Subject: [PATCH] deploy-flake: always use target hostname for safety --- deploy-flake.sh | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/deploy-flake.sh b/deploy-flake.sh index 8fd40c8c..2727acd3 100755 --- a/deploy-flake.sh +++ b/deploy-flake.sh @@ -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