-
-
Save ixxie/fda90b1b4e3656f297980e91a883615e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Script to use Clever's kexec method to install NixOS on a Hetzner Cloud VM | |
TARGET=$1 | |
printf "\n<<Copying kexec tarball to target>>\n" | |
scp -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null \ | |
./nix-tests/kexec/result/tarball/nixos-system-x86_64-linux.tar.xz root@${TARGET}:/ | |
printf "\n<<Running kexec on target>>\n" | |
ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null \ | |
root@${TARGET} "cd / && tar -xf nixos-system-x86_64-linux.tar.xz && ./kexec_nixos" | |
sleep 32 | |
printf "\n<<Formatting disk & generating configuration>>\n" | |
ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null root@${TARGET} \ | |
"mkfs.ext4 -F /dev/sda1 && mount /dev/sda1 /mnt && nixos-generate-config --root /mnt" | |
printf "\n<<Copying temporary configuration to target>>\n" | |
scp -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null \ | |
./temp-config.nix root@${TARGET}:/mnt/etc/nixos/configuration.nix | |
printf "\n<<Installing NixOS>>\n" | |
ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null \ | |
root@${TARGET} "nixos-install && reboot" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment