my nix configs for my servers and desktop
1{ config, lib, system, pkgs, modulesPath, inputs, ... }: 2 3{ 4 programs.virt-manager.enable = true; 5 virtualisation.spiceUSBRedirection.enable = true; 6 virtualisation.libvirtd = { 7 enable = true; 8 qemu = { 9 package = pkgs.qemu_kvm; 10 runAsRoot = true; 11 swtpm.enable = true; 12 ovmf = { 13 enable = true; 14 packages = [(pkgs.OVMF.override { 15 secureBoot = true; 16 tpmSupport = true; 17 }).fd]; 18 }; 19 }; 20 hooks.qemu = { 21 win11 = ./scripts/vm-win11-hook.sh; 22 }; 23 }; 24 25 systemd.services.libvirtd = { 26 path = let 27 env = pkgs.buildEnv { 28 name = "qemu-hook-env"; 29 paths = with pkgs; [ 30 bash 31 libvirt 32 kmod 33 systemd 34 ripgrep 35 sd 36 ]; 37 }; 38 in 39 [ env ]; 40 }; 41 42 users.extraUsers.regent.extraGroups = [ "libvirtd" ]; 43}