# /etc/nixos/vm-guest.nix # Erweiterte Virtualisierungs-Konfiguration # Diese Datei ist optional und kann in configuration.nix importiert werden { config, pkgs, ... }: { # QEMU/KVM mit erweiterten Optionen virtualisation.libvirtd = { enable = true; qemu = { package = pkgs.qemu_kvm; runAsRoot = true; # TPM Emulation für Windows 11 VMs swtpm.enable = true; # UEFI Support ovmf = { enable = true; packages = [ pkgs.OVMFFull.fd ]; }; }; }; # Virt-Manager und virtuelle Netzwerke programs.virt-manager.enable = true; # Networking für VMs networking.firewall = { # Erlaube Bridged Networking checkReversePath = false; }; # libvirt Netzwerk-Bridge # Erstellt ein "default" NAT-Netzwerk für VMs systemd.services.libvirtd-config = { description = "Setup libvirt default network"; after = [ "libvirtd.service" ]; requires = [ "libvirtd.service" ]; wantedBy = [ "multi-user.target" ]; serviceConfig = { Type = "oneshot"; RemainAfterExit = true; }; script = '' ${pkgs.libvirt}/bin/virsh net-autostart default || true ${pkgs.libvirt}/bin/virsh net-start default || true ''; }; # Zusätzliche VM-Tools environment.systemPackages = with pkgs; [ virt-viewer # VNC/SPICE Viewer spice-gtk # SPICE Client win-virtio # Windows VirtIO Treiber ]; # Performance-Tuning für VMs boot.kernelModules = [ "kvm-amd" ]; # Für AMD CPUs (für Intel: "kvm-intel") # Hugepages für bessere VM Performance (optional) # boot.kernelParams = [ "hugepagesz=2M" "hugepages=2048" ]; }