From 427ee38d7aa633049ac9b34d09f36f6a76baf1cd Mon Sep 17 00:00:00 2001 From: Don Harper Date: Wed, 18 Sep 2024 16:37:37 -0500 Subject: [PATCH] updates to deploy-host --- deploy-host | 38 ++++++++++++++++++++------------ nixos-anywhere/configuration.nix | 1 + 2 files changed, 25 insertions(+), 14 deletions(-) diff --git a/deploy-host b/deploy-host index 8ab2209..0c666ff 100755 --- a/deploy-host +++ b/deploy-host @@ -4,7 +4,7 @@ set -o errexit set -o errtrace # set -o nounset -debug=echo +# debug=echo if [ "x" == "x$2" ] then @@ -14,22 +14,32 @@ fi nixanywhere=~/nixos/nixos-anywhere nixsrc=~/nixos -ip="${1}" -host="${2}" +ip=${1} +host=${2} -if [ ! -f "${nixsrc}/hosts/${host}/default.nix" ] +if [ ! -f ${nixsrc}/hosts/${host}/default.nix ] then echo "Please set up ${nixsrc}/hosts/${host}/default.nix before running" exit 1 fi -${debug} cd "${nixanywhere}" -${debug} ssh-keygen -R "${ip}" -${debug} nix run github:nix-community/nixos-anywhere -- --flake .#${host} root@"${ip}" -${debug} cd "${nixsrc}" -${debug} ssh-keygen -R "${ip}" -${debug} ssh root@"${ip}" nixos-generate-config -${debug} scp root@"${ip}":/etc/nixos/hardware-configuration.nix hosts/${host}/hardware-configuration.nix -${debug} git add hosts/${host}/hardware-configuration.nix -${debug} nixos-rebuild switch --flake .#${host} --target-host "root@"${ip}"" -${debug} rsync -av ~/.ssh ~/bin don@"${ip}": +cd ${nixanywhere} +ssh-keygen -R ${ip} +nix run github:nix-community/nixos-anywhere -- --flake .#${host} root@${ip} +cd ${nixsrc} +sleep 5 +until ping -c1 ${ip} +do + sleep 5 +done +ssh-keygen -R ${ip} +ssh -o StrictHostKeyChecking=accept-new root@${ip} nixos-generate-config +scp root@${ip}:/etc/nixos/hardware-configuration.nix hosts/${host}/hardware-configuration.nix +git add hosts/${host}/hardware-configuration.nix +nixos-rebuild switch --flake .#${host} --target-host root@${ip} +sleep 5 +until ping -c1 ${ip} +do + sleep 5 +done +rsync -av ~/.ssh ~/bin don@${ip}: diff --git a/nixos-anywhere/configuration.nix b/nixos-anywhere/configuration.nix index 7e331fa..7d3d7fb 100644 --- a/nixos-anywhere/configuration.nix +++ b/nixos-anywhere/configuration.nix @@ -59,6 +59,7 @@ "vm.swappiness" = 10; }; }; + }; services.openssh.enable = true;