#!/bin/bash usage() { cat <&2 exit 64 ;; esac done shift $((OPTIND - 1)) if [ -z ${identityFile} ]; then echo "missing option: -i is required" >&2 usage >&2 exit 64 fi if [ -z $(type -P "scp") ] || [ -z $(type -P "ssh") ]; then echo "SSH needs to be installed" >&2 exit 64 fi echo "Please open $(tput bold)https://nixos.org/download#nixos-amazon$(tput sgr0) and follow the instructions to launch an EC2 instance. $(tput bold)Note: it's recommended to use a disk size of >=20GB.$(tput sgr0)" echo read -p "Domain or IP of launched EC2 instance: " host echo echo "$(tput bold)Copying configuration to ${host}...$(tput sgr0)" scp -i "${identityFile}" ./configuration.nix root@"${host}":/etc/nixos/configuration.nix echo "$(tput bold)Building system...$(tput sgr0)" ssh -i "${identityFile}" root@"${host}" "nixos-rebuild switch --upgrade"