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