NixVirt provides a NixOS module and a Home Manager module for defining virtual machines (known as “domains”) and networks using libvirt.
Whereas existing NixOS allows you to control the libvirtd daemon, NixVirt allows you to specify domains using libvirt’s XML definition format, and whether they should be running. You can use these domains with libvirt clients such as virt-manager or GNOME Boxes.
I am currently working on providing Nix functions to generate these XML definitions from Nix structures, for a more Nix-like experience.
builtins.toXML generates XML in Nix’s own XML schema (for Nix structures). It cannot create XML in libvirt’s domain definition or network definition XML schemas.
Thank you for this module! It’s exactly what I’m looking for. However, I’m having trouble integrating it into my NixOS config. I’m fairly new to NixOS so might be something I’m doing wrong. Do you have any full working example you can point me to? Here is what I have.
I figured it out. I needed to import the nixvirt.nixosModules.default module in order to make the options available in my configuration module. If anyone else is looking for a concrete example, here is a commit that adds NixVirt and a couple of network definitions to a NixOS system.