I moved a VM to my NixOS workstation and used libvirt to run it, but ran into an issue a few weeks later after rebooting post-updates. Turns out that by default the virt-manager GUI will hardcode some paths for configuration items, and of course, when using NixOS these will change after updates.

Example:

  <os firmware="efi">
    <type arch="x86_64" machine="pc-q35-9.1">hvm</type>
    <firmware>
      <feature enabled="no" name="enrolled-keys"/>
      <feature enabled="yes" name="secure-boot"/>
    </firmware>
    <loader readonly="yes" secure="yes" type="pflash">/nix/store/ddf1vssb23g4jbdivhfgwi0iaimpz7my-qemu-9.1.3/share/qemu/edk2-x86_64-secure-code.fd</loader>
    <nvram template="/nix/store/ddf1vssb23g4jbdivhfgwi0iaimpz7my-qemu-9.1.3/share/qemu/edk2-i386-vars.fd">/var/lib/libvirt/qemu/nvram/vmname_VARS.fd</nvram>
    <boot dev="hd"/>
  </os>

I wish I had a better fix- but this seems to work:

  1. sudo virsh edit vmname
  2. Remove both lines starting with <loader and <nvram
  3. Start VM (which seems to automatically populate the lines)

I’m certain there’s a better way to do this but I haven’t figured out how to automatically populate the path as the path updates on a regular basis.