qemu options
This commit is contained in:
@@ -3,6 +3,6 @@
|
||||
imports = [
|
||||
./podman.nix
|
||||
./qemu.nix
|
||||
./lima.nix
|
||||
./options.nix
|
||||
];
|
||||
}
|
||||
|
||||
@@ -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.";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
})
|
||||
];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user