Run NixOS on an Azure Gen 2 VM
- Set your username in the
flake.nix
file - use direnv or run
nix develop
- run
az login
and login with your Azure credentials - Create an RSA SSH key pair (id_rsa) - ed25519 keys are not supported by Azure
it can take a while to upload the .vhd
(for me it is +/- 50 min),
if the upload time-out; you may want to change the token duration.
also don't look at the azcopy log file, it spams 500 errors but these can be ignored..
./upload-image.sh --resource-group images --image-name nixos-gen2
./boot-vm.sh --resource-group vms --image nixos-gen2 --vm-name nixos
nix build .#azure-image --impure
ssh -i ~/.ssh/id_rsa <username>@<public_ip>
- username you have set in the
flake.nix
file- public IP will be printed with running the
boot-vm.sh
script
❯ neofetch
▗▄▄▄ ▗▄▄▄▄ ▄▄▄▖ rudesome@nixos
▜███▙ ▜███▙ ▟███▛ --------------
▜███▙ ▜███▙▟███▛ OS: NixOS 23.11.20240215.c68a9fc (Tapir) x86_64
▜███▙ ▜██████▛ Host: Microsoft Corporation Virtual Machine
▟█████████████████▙ ▜████▛ ▟▙ Kernel: 6.7.4
▟███████████████████▙ ▜███▙ ▟██▙ Uptime: 45 secs
▄▄▄▄▖ ▜███▙ ▟███▛ Packages: 368 (nix-system), 798 (nix-user)
▟███▛ ▜██▛ ▟███▛ Shell: zsh 5.9
▟███▛ ▜▛ ▟███▛ Terminal: /dev/pts/0
▟███████████▛ ▟██████████▙ CPU: Intel Xeon Platinum 8171M (1) @ 2.095GHz
▜██████████▛ ▟███████████▛ Memory: 384MiB / 3424MiB
▟███▛ ▟▙ ▟███▛
▟███▛ ▟██▙ ▟███▛
▟███▛ ▜███▙ ▝▀▀▀▀
▜██▛ ▜███▙ ▜██████████████████▛
▜▛ ▟████▙ ▜████████████████▛
▟██████▙ ▜███▙
▟███▛▜███▙ ▜███▙
▟███▛ ▜███▙ ▜███▙
▝▀▀▀ ▀▀▀▀▘ ▀▀▀▘