qemu options

This commit is contained in:
2026-07-05 21:50:21 -05:00
parent b1a872b511
commit dff5e2cb5e
3 changed files with 64 additions and 22 deletions
+1 -1
View File
@@ -3,6 +3,6 @@
imports = [ imports = [
./podman.nix ./podman.nix
./qemu.nix ./qemu.nix
./lima.nix ./options.nix
]; ];
} }
+29
View File
@@ -24,5 +24,34 @@ in
default = false; default = false;
}; };
}; };
# qemu
qemu = {
enable = lib.mkEnableOption "QEMU support";
containers = lib.mkEnableOption "Enable container support for QEMU" {
enable = true;
default = false;
};
spiceUSBRedirection = lib.mkEnableOption "Enable spice USB redirection support for QEMU" {
enable = true;
default = false;
};
virtManager = lib.mkEnableOption "Enable virt-manager support for QEMU" {
enable = true;
default = false;
};
bootModules = lib.mkOption {
type = lib.types.listOf lib.types.str;
default = [
"kvm-intel"
"kvm-amd"
];
description = "The kernel modules to load for QEMU support.";
};
};
}; };
} }
+24 -11
View File
@@ -1,8 +1,15 @@
{ pkgs, ... }:
{ {
virtualisation.spiceUSBRedirection.enable = true; config,
lib,
pkgs,
...
}:
let
cfg = config.homelab.virtualization;
in
{
config = lib.mkMerge [
(lib.mkIf cfg.qemu.enable {
virtualisation = { virtualisation = {
containers.enable = true; containers.enable = true;
libvirtd = { libvirtd = {
@@ -13,16 +20,22 @@
}; };
}; };
}; };
users.users.${cfg.user}.extraGroups = [
programs.virt-manager.enable = true;
users.users.river.extraGroups = [
"libvirtd" "libvirtd"
"kvm" "kvm"
]; ];
})
boot.kernelModules = [ (lib.mkIf cfg.qemu.spiceUSBRedirection {
"kvm-intel" virtualisation.spiceUSBRedirection.enable = true;
"kvm-amd" })
(lib.mkIf cfg.qemu.virtManager {
programs.virt-manager.enable = true;
})
(lib.mkIf cfg.qemu.bootModules {
boot.kernelModules = cfg.qemu.bootModules;
})
]; ];
} }