#!/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=~/nixos/nixos-anywhere nixsrc=~/nixos 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} ssh-keygen -R ${ip} nix run github:nix-community/nixos-anywhere -- --flake .#${host} root@${ip} cd ${nixsrc} sleep 5 until ping -c1 ${ip} do echo "===========================================================" echo "= Log onto ${host} root/changeme and run nmcli if on WiFi =" echo "===========================================================" notify-send --urgency=critical --icon=rocket "Log onto ${host} root/changeme and run nmcli if on WiFi" 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} notify-send --urgency=critical --expire-time=0 --icon=cdrom "Remove boot iso" read -p 'remove iso from target' foo just switch ${host} sleep 5 until ping -c1 ${ip} do sleep 5 done rsync -av ~/.ssh ~/bin don@${ip}: