{ config, lib, pkgs, ... }: { config = lib.mkIf config.virtualisation.libvirtd.enable { virtualisation.libvirtd = { onBoot = "ignore"; onShutdown = "shutdown"; qemu = { ovmf = { enable = true; packages = with pkgs; [ OVMFFull.fd ]; }; vhostUserPackages = with pkgs; [ virtiofsd ]; swtpm.enable = true; }; }; # Isolate devices into more IOMMU groups boot.kernelParams = [ "pcie_acs_override=downstream,multifunction" "pci=routeirq" ]; # Enable the gui manager programs.virt-manager.enable = builtins.elem "pc" config.system.nixos.tags; # Allow looking glass to be accessed by users systemd.tmpfiles.rules = [ "f /dev/shm/looking-glass 0660 - libvirtd -" ]; environment.persistence."/persist".directories = [ "/var/lib/libvirt" ]; }; }