Files
nixos/modules/virtualization.nix
Melvin Ragusa 2505298449 Normalize Nix module formatting and update flake.lock
Consistently format module argument blocks and convert aligned
package comments to inline comments. Trim trailing whitespace and
minor layout tweaks across modules. Bump opencode rev, narHash and
lastModified in flake.lock and remove the original dev ref.
2026-02-02 18:08:01 +01:00

62 lines
3.4 KiB
Nix

# modules/virtualization.nix
# Virtual machine support: QEMU, KVM, libvirt, virt-manager
{
config,
pkgs,
lib,
...
}:
{
# ═══════════════════════════════════════════════════════════════
# LIBVIRT & QEMU
# ═══════════════════════════════════════════════════════════════
virtualisation.libvirtd = {
enable = true;
# QEMU configuration
qemu = {
package = pkgs.qemu_kvm;
# Enable TPM emulation for Windows 11
swtpm.enable = true;
# Run QEMU as non-root for better security
runAsRoot = false;
};
};
# ═══════════════════════════════════════════════════════════════
# SPICE SUPPORT (for better VM display/clipboard/USB)
# ═══════════════════════════════════════════════════════════════
virtualisation.spiceUSBRedirection.enable = true;
# ═══════════════════════════════════════════════════════════════
# NETWORKING FOR VMS
# ═══════════════════════════════════════════════════════════════
# Enable default NAT network (virbr0)
networking.firewall.trustedInterfaces = [ "virbr0" ];
# ═══════════════════════════════════════════════════════════════
# PACKAGES
# ═══════════════════════════════════════════════════════════════
environment.systemPackages = with pkgs; [
virt-manager # GUI for managing VMs
virt-viewer # Viewer for VM displays (SPICE/VNC)
virtiofsd # Fast file sharing between host and VM
qemu-utils # QEMU utilities (qemu-img, etc.)
spice-gtk # SPICE client libraries
];
# ═══════════════════════════════════════════════════════════════
# USER PERMISSIONS
# ═══════════════════════════════════════════════════════════════
users.users.pinj.extraGroups = [ "libvirtd" ];
# ═══════════════════════════════════════════════════════════════
# DCONF SETTINGS FOR VIRT-MANAGER
# ═══════════════════════════════════════════════════════════════
# Auto-connect to the system QEMU/KVM
programs.virt-manager.enable = true;
}