1. Security: Navidrome no longer exposed to network (localhost only) 2. Maintainability: Single username definition in flake.nix:45 3. Organization: Kernel params now in configuration.nix, session vars in desktop.nix 4. Automation: Flathub repository added automatically on activation 5. Cleanup: Removed duplicate programs.dconf.enable
63 lines
3.4 KiB
Nix
63 lines
3.4 KiB
Nix
# modules/virtualization.nix
|
|
# Virtual machine support: QEMU, KVM, libvirt, virt-manager
|
|
{
|
|
config,
|
|
pkgs,
|
|
lib,
|
|
username,
|
|
...
|
|
}:
|
|
|
|
{
|
|
# ═══════════════════════════════════════════════════════════════
|
|
# 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.${username}.extraGroups = [ "libvirtd" ];
|
|
|
|
# ═══════════════════════════════════════════════════════════════
|
|
# DCONF SETTINGS FOR VIRT-MANAGER
|
|
# ═══════════════════════════════════════════════════════════════
|
|
# Auto-connect to the system QEMU/KVM
|
|
programs.virt-manager.enable = true;
|
|
}
|