I am running a headless NixOS server and would like to know what’s the easiest/“best” way to run VMs on such a system. So far I’ve found close to nothing, and the guides I find seem to focus on non-headless NixOS installations, as trying to run VMs on my box yield DISPLAY is not set errors and similar.
Incus and LXD are both in nixpkgs, and while they originally focused on running containers, they have reasonably mature VM support now too. There’s a web front-end at least for Incus (probably LXD too) which allows you to do most things, access consoles, etc. Some of the most sophisticated qemu functionality might not be there, but all the basics are.
Otherwise, libvirt is also in nixpkgs, and you can connect to that remotely from another box using virsh or virt-manager. There’s also NixVirt if you want to fully declaratively define libvirt VMs using nix format rather than than libvirt’s native XML.
I’ve finally migrated my main homelab server (a fairly low-spec nuc) to NixOS and at the moment I’m doing a mix of incus and libvirt (I’ll probably fully migrate to the latter eventually due to a few missing features in incus.)
Oh, I should have mentioned Proxmox-NixOS as well! I haven’t found an excuse to try it yet but it looks very promising - presumably it would be of particular benefit for anyone with previous proxmox experience.