VM Creations on libvirt

I have a nix-build vm.nix setup which I have a set of virtual machines configuration. I use a similar qubes os configuration, each vm having it’s own scope and etc. Nothing more than that.
Right now I find kinda cumbersome to manage each vm by starting with ./result/bin/run-nixos-vm and I would like to know it there is a way to integrate this setup to libvirt, this way I can manage each vm with the virt-manager gui, which I find it better for visualization and sometimes to adjust a minor tweak to test and not necessarily building the vm again.
I don’t know if the nixos-generators is the way and the domxml-from-native have been removed (kvm - Qemu Native to Libvirt XML - Stack Overflow).

Thanks in advance

1 Like

I stumbled upon your question as I was looking for something similar. Continuing the search, I ended up boiling it down to the following options:

  • Use libvirt as described in Libvirt - NixOS Wiki : with the NixOS module to setup the host, and leverage virsh to manage networks and clients;
  • NixVirt (from @AshleyYakeley) that seems to allow to declaratively manage networks and clients (domains in libvirt terminology) through XML;
  • MicroVM.nix (from @astro) that seems to provide another layer of abstraction for declaration as nix code, supports multiple virtual machines backends (hypervisor-ish), and also ships a module for managing the running of said VMs on a host - c.f. NixCon 2023 presentation.
1 Like