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 = [
./podman.nix
./qemu.nix
./lima.nix
./options.nix
];
}
+29
View File
@@ -24,5 +24,34 @@ in
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.";
};
};
};
}
+34 -21
View File
@@ -1,28 +1,41 @@
{ pkgs, ... }:
{
virtualisation.spiceUSBRedirection.enable = true;
virtualisation = {
containers.enable = true;
libvirtd = {
enable = true;
qemu = {
package = pkgs.qemu_kvm;
swtpm.enable = true;
config,
lib,
pkgs,
...
}:
let
cfg = config.homelab.virtualization;
in
{
config = lib.mkMerge [
(lib.mkIf cfg.qemu.enable {
virtualisation = {
containers.enable = true;
libvirtd = {
enable = true;
qemu = {
package = pkgs.qemu_kvm;
swtpm.enable = true;
};
};
};
};
};
users.users.${cfg.user}.extraGroups = [
"libvirtd"
"kvm"
];
})
programs.virt-manager.enable = true;
(lib.mkIf cfg.qemu.spiceUSBRedirection {
virtualisation.spiceUSBRedirection.enable = true;
})
users.users.river.extraGroups = [
"libvirtd"
"kvm"
];
(lib.mkIf cfg.qemu.virtManager {
programs.virt-manager.enable = true;
})
boot.kernelModules = [
"kvm-intel"
"kvm-amd"
(lib.mkIf cfg.qemu.bootModules {
boot.kernelModules = cfg.qemu.bootModules;
})
];
}