feat(libvirt): service configuration and persist

This commit is contained in:
514fpv 2024-01-03 16:59:17 +08:00
parent ca9471bfb3
commit a56f98417d
Signed by: koishi
SSH key fingerprint: SHA256:axz0uIzzY+5W19i7QOUuiw5LSqhKfCBKPf3L4xFRxLw

View file

@ -0,0 +1,30 @@
{ pkgs
, lib
, config
, ... }: with lib; let
cfg = config.faucet.libvirt;
in {
options.faucet.libvirt = {
enable = mkEnableOption "libvirt virtualisation daemon" // { default = true; };
};
config = mkIf cfg.enable {
virtualisation.libvirtd = {
enable = true;
qemu.runAsRoot = false;
qemu.swtpm.enable = true;
# disable as much implicit state as possible
onBoot = "ignore";
onShutdown = "shutdown";
parallelShutdown = 5;
};
# USB redirection requires a setuid wrapper
virtualisation.spiceUSBRedirection.enable = true;
environment.persistence."/nix/persist/fhs".directories = [
"/var/lib/libvirt"
];
};
}