diff --git a/deploy-host b/deploy-host new file mode 100755 index 0000000..0fccb9f --- /dev/null +++ b/deploy-host @@ -0,0 +1,34 @@ +#!/usr/bin/env bash + +set -o errexit +set -o errtrace +set -o nounset + +debug=echo + +if [ "x" == "x$2" ] +then + echo "usage: $0 " + exit 1 +fi + +nixanywhere=~/src/nixos/nixos-anywhere-examples +nixsrc=~/src/nixos/duckland +ip="${1}" +host="${2}" + +if [ ! -f "${nixsrc}/hosts/${host}/default.nix" ] +then + echo "Please set up ${nixsrc}/hosts/${host}/default.nix before running" + exit 1 +fi + +cd "${nixanywhere}" +${debug} ssh-keygen -R "${ip}" +${debug} nix run github:nix-community/nixos-anywhere -- --flake .#${host} root@"${ip}" +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}""