skip to content
alvaro_sh

NixOS install on Proxmox

| 2 min read

This is a simplified guide to setup NixOS on a Proxmox virtual machine, extracted from different sources:

Creating Proxmox VM

Follow the section Creating the NixOS VM to the letter, with the exception of the selected ISO image.

Next steps will not need any graphical interface so using the Minimal ISO will be enough and better as it has a smaller size.

Installing and configuring NixOS

Starting a console on the VM. It should show a NixOS menu, select first option or leave it for a bit, it should then show a console.

NixOS is installed with a passwordless nixos user, start sudo:

sudo -i

Create and mount partitions

Find out the name of the disk with

lsblk

Create partitions as defined NixOS Manual | UEFI (GPT). We can use any tool but cfdisk has a nice UI

cfdisk /dev/sda/

Select gpt and then create the following partitions:

  • A EFI System type, size: 1G -> /dev/sda1
  • A Linux swap type, size 4G -> /dev/sda2
  • Last one with the remaining size, Linux filesystem -> /dev/sda3

Go to Write and confirm all, then Quit. Run lsblk to confirm the partitions have been created.

Now, format the created partitions

mkfs.ext4 -L nixos /dev/sda3
mkswap -L swap /dev/sda2
mkfs.fat -F 32 -n boot /dev/sda1

Finally, mount them

mount /dev/sda3 /mnt
mount --mkdir /dev/sda1 /mnt/boot
swapon /dev/sda2

Generate NixOS config

To start configuring NixOS, we need to generate the configuration file

nixos-generate-config --root /mnt

It will generate two files /mnt/dev/nixos/configuration.nix and /mnt/dev/nixos/hardware-configuration.nix. Feel free to start tinkering with the configuration.nix file, as a minimum setting up you own user.

Once happy, run nixos-install. It will take a few seconds and once completed will prompt for root user password.

Last step is setting a password for your configured user

nixos-enter --root /mnt -c 'passwd alv'

Then we can

reboot

the system, after which we should be prompted to select Nixos and select a user and password to enter.

Conclusion

This should get NixOS installed and running on a Proxmos Virtual Machine. Remember to run nixos-rebuild switch on after changes on the configuration file.