This guide walks through setting up a NixOS virtual machine in Unraid from scratch. The goal is a minimal, declarative server that you can use as a base for self-hosted services. We’ll cover creating the VM, partitioning the disk, installing NixOS with a sensible server configuration, and getting SSH access working.
NixOS uses a single configuration file to define the entire system — packages, users, services, networking. This means the setup is reproducible and can be version-controlled. Instead of running commands to install packages and edit config files across the system, everything lives in configuration.nix.
This guide is a simplified walkthrough based on the official NixOS installation manual, combined for x86_64, UEFI, and Unraid. Refer to the official docs for edge cases or alternative setups.
1. Download the NixOS minimal ISO#
This guide uses the x86_64 image. NixOS also provides an aarch64 (ARM64) build, but the steps below are written for x86_64.
Grab the minimal ISO image for x86_64 from the NixOS download page. Choose the latest minimal installer image and place the .iso file in your Unraid ISO share (typically /mnt/user/isos/).
2. Set up the Unraid VM#
Create a new VM in Unraid using the Linux template. I used the following settings but feel free to adjust them to your needs:
| Setting | Value |
|---|---|
| Firmware | UEFI (OVMF) |
| Machine type | pc-q35-10.2 |
| CPU | 2 vCPU, host-passthrough |
| Memory | 4096 MB |
| Disk bus | virtio (raw, writeback) |
| Network | virtio-net, bridged to br0 |
| ISO | nixos-minimal-x86_64-linux.iso |
This guide assumes a UEFI boot setup. The VM must use OVMF firmware — a BIOS/SeaBIOS VM will not work with the partition layout and boot loader configuration below.
3. Partition the disk#
Boot the VM from the ISO. You’ll be logged in as the nixos user — switch to root with sudo -i.
parted /dev/vda -- mklabel gpt
parted /dev/vda -- mkpart ESP fat32 1MB 512MB
parted /dev/vda -- set 1 esp on
parted /dev/vda -- mkpart root ext4 512MB 100%Check:
lsblkYou should see roughly:
vda
├─vda1 511M
└─vda2 <rest of disk>4. Format the partitions#
mkfs.fat -F 32 -n BOOT /dev/vda1
mkfs.ext4 -L nixos /dev/vda2No swap partition — for a self-hosted server the RAM allocation is predictable, so swap is rarely needed. You can always add a swap file later if a service requires it.
5. Mount the root filesystem#
mount /dev/disk/by-label/nixos /mntWe use the disk label (nixos) instead of /dev/vda2 so the mount survives disk order changes.
6. Mount the EFI partition#
mkdir -p /mnt/boot
mount -o umask=077 /dev/disk/by-label/BOOT /mnt/bootYou can verify:
lsblk -o NAME,SIZE,FSTYPE,LABEL,MOUNTPOINTSYou should see:
vda
├─vda1 vfat BOOT /mnt/boot
└─vda2 ext4 nixos /mnt7. Generate the NixOS configuration#
nixos-generate-config --root /mntThis auto-detects your hardware and creates two files:
/mnt/etc/nixos/configuration.nix # main config — you edit this
/mnt/etc/nixos/hardware-configuration.nix # auto-generated — leave as-is8. Edit the configuration#
nano /mnt/etc/nixos/configuration.nixReplace the entire file with this minimal but solid starting point for a VPS server:
{ config, pkgs, ... }:
{
imports = [
./hardware-configuration.nix
];
boot.loader.systemd-boot.enable = true;
networking.hostName = "nixos";
# NetworkManager is for desktops — disabled on a static server
networking.networkmanager.enable = false;
# Check the interface name with `ip link` before editing
networking.interfaces.ens3.useDHCP = true;
time.timeZone = "Europe/Berlin";
i18n.defaultLocale = "en_US.UTF-8";
users.users.flohoss = {
isNormalUser = true;
description = "Florian Hoss";
# wheel group grants sudo privileges
extraGroups = [ "wheel" ];
# Key-only login — no password needed for SSH
openssh.authorizedKeys.keys = [
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAI... your-key-here"
];
};
services.openssh = {
enable = true;
settings = {
PermitRootLogin = "no";
PasswordAuthentication = false;
};
};
networking.firewall.enable = true;
networking.firewall.allowedTCPPorts = [ 22 ];
environment.systemPackages = with pkgs; [ vim ];
}Replace the SSH key, username, and hostname with your own values. The interface name (ens3) may differ — check it with ip link before editing.
To set a password for the user (needed for sudo), run mkpasswd -m sha-512 on the installer and paste the hash into users.users.flohoss.hashedPassword.
9. Install NixOS#
Once your configuration is ready:
nixos-install --root /mntIt will ask you to set/confirm the root password. Once the install finishes, you can unmount:
umount /mnt/boot /mnt10. Reboot#
rebootThen remove/disable the NixOS installer ISO in Unraid so the VM boots from /dev/vda.
After reboot, log in via SSH with your user and key:
ssh flohoss@<vm-ip>To rebuild the system after future config changes:
sudo nixos-rebuild switch