1
0
Fork 0

Add virtualization module

This commit is contained in:
Aires 2024-05-22 16:47:55 -04:00
parent 072ee60680
commit ee37af2ff9
4 changed files with 65 additions and 1 deletions

View file

@ -79,6 +79,10 @@ in
enable = true;
ports = [ config.secrets.hosts.haven.ssh.port ];
};
virtualization = {
enable = true;
user = "aires";
};
};
users.aires = {
enable = true;

View file

@ -66,6 +66,9 @@ in
# Install additional packages
environment.systemPackages = [ pkgs.boinc ];
# Enable virtual machine manager
programs.virt-manager.enable = true;
# Move files into target system
systemd.tmpfiles.rules = [
# Use gremlin user's monitor config for GDM (defined above)

View file

@ -35,7 +35,7 @@ in
};
config = mkIf cfg.enable {
config = lib.mkIf cfg.enable {
# Add changes applied by this module here.
};
}

View file

@ -0,0 +1,57 @@
# Enables virtualization via QEMU/KVM
{
config,
lib,
pkgs,
...
}:
let
cfg = config.host.services.virtualization;
in
{
options = {
host.services.virtualization = {
enable = lib.mkEnableOption (lib.mdDoc "Enables virtualization hosting tools on this host.");
user = lib.mkOption {
default = "";
type = lib.types.str;
description = "The default user to add as a KVM admin.";
};
};
};
config = lib.mkIf cfg.enable {
virtualisation = {
libvirtd = {
enable = true;
qemu = {
package = pkgs.qemu_kvm;
swtpm.enable = true;
ovmf.enable = true;
ovmf.packages = [ pkgs.OVMFFull.fd ];
};
};
spiceUSBRedirection.enable = true;
};
users.users.${cfg.user}.extraGroups = [ "libvirtd" ];
environment.systemPackages = with pkgs; [
spice
spice-gtk
spice-protocol
virt-viewer
];
programs.virt-manager.enable = true;
home-manager.users.${cfg.user} = {
dconf.settings = {
"org/virt-manager/virt-manager/connections" = {
autoconnect = [ "qemu:///system" ];
uris = [ "qemu:///system" ];
};
};
};
};
}