Add virtualization module
This commit is contained in:
parent
072ee60680
commit
ee37af2ff9
|
@ -79,6 +79,10 @@ in
|
||||||
enable = true;
|
enable = true;
|
||||||
ports = [ config.secrets.hosts.haven.ssh.port ];
|
ports = [ config.secrets.hosts.haven.ssh.port ];
|
||||||
};
|
};
|
||||||
|
virtualization = {
|
||||||
|
enable = true;
|
||||||
|
user = "aires";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
users.aires = {
|
users.aires = {
|
||||||
enable = true;
|
enable = true;
|
||||||
|
|
|
@ -66,6 +66,9 @@ in
|
||||||
# Install additional packages
|
# Install additional packages
|
||||||
environment.systemPackages = [ pkgs.boinc ];
|
environment.systemPackages = [ pkgs.boinc ];
|
||||||
|
|
||||||
|
# Enable virtual machine manager
|
||||||
|
programs.virt-manager.enable = true;
|
||||||
|
|
||||||
# Move files into target system
|
# Move files into target system
|
||||||
systemd.tmpfiles.rules = [
|
systemd.tmpfiles.rules = [
|
||||||
# Use gremlin user's monitor config for GDM (defined above)
|
# Use gremlin user's monitor config for GDM (defined above)
|
||||||
|
|
|
@ -35,7 +35,7 @@ in
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
config = mkIf cfg.enable {
|
config = lib.mkIf cfg.enable {
|
||||||
# Add changes applied by this module here.
|
# Add changes applied by this module here.
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
57
modules/services/virtualization.nix
Normal file
57
modules/services/virtualization.nix
Normal 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" ];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
Loading…
Reference in a new issue