Hi everyone. Thank you all for your responses, they have been incredibly insightful. I think this is going to be an area for continuing growth and personal development for me over the next few months and I’m going to see if I can get around to trying a variety of the options presented here
I think I have refined my understanding enough to see that the initial framing of the question was wrong. There is no such thing as a provider for nixos because nixos is not a virualisation management platform. As others responding have pointed out, this is something like K3s, libvirtd, etc. which are dedicated software that run on top of the operating system and are not managed with nix directly. My previous attempts were based around building and managing QEMU VMs directly with nix, which explains why I was running into so many management hurdles as I was effectively reinventing the wheel.
For now I am exploring setting up nixos hypervisors running libvirtd as the management layer, with which I will use opentofu and the dmacvicar/libvirt provider (which speaks to the libvirt api on behalf of opentofu) to provision VMs and networks.
Hi, NixOS maintainer for Xen here. You don’t want to use Xen for this right now. I share your goal, but there are years of work needed before our implementation of Xen is viable for what you want.
I have a deployment tool I use both personally and commerically, essentially a fork of colmena that (quoting my own docs):
Provisioning, creating the machine through terranix.
Installation, putting NixOS onto it with nixos-anywhere.
Disk decryption, unlocking encrypted volumes in initrd.
Configuration switching, activating the target NixOS configuration.
Basically, think colmena with built in terranix, nixos-anywhere, provenance/update tracking. Also does stuff like templating terranix outputs into “facts” that you can then e.g. substitute into your config, i.e. so you don’t have to specify IPs, domains, anything like this, just get it from whatever opentofu actually did.
It’s pretty complicated as a warning, but also quite powerful. Also can use this with domain delegation etc. against porkbun (which seems to have the best api), I have a opentofu (terraform) provider fork that adds support for this here as well.
I was just coming back here to see if anyone had mentioned terranix, as I realised that terraform felt very similar syntactically and was thinking surely someone had done that… lo and behold
That’s really awesome and impressive! I shall have a peek at that when I am a bit more familiar with working with terraform and colmena independently.