services.kvm: add nodatacow option

This commit is contained in:
2025-05-06 11:56:43 +08:00
parent 0d96e6322d
commit 6cece7d3b9
3 changed files with 13 additions and 5 deletions

View File

@@ -19,7 +19,7 @@ inputs:
{
xray.client.enable = true;
beesd."/".threads = 4;
kvm = {};
kvm.nodatacow = true;
};
};
boot.initrd.systemd.network.networks."10-eno2" = inputs.config.systemd.network.networks."10-eno2";

View File

@@ -4,6 +4,7 @@ inputs:
{
type = types.nullOr (types.submodule { options =
{
nodatacow = mkOption { type = types.bool; default = false; };
autoSuspend = mkOption { type = types.listOf types.nonEmptyStr; default = []; };
};});
default = null;
@@ -38,7 +39,12 @@ inputs:
};
spiceUSBRedirection.enable = true;
};
environment.systemPackages = with inputs.pkgs; [ qemu_full win-spice guestfs-tools virt-manager ];
environment =
{
persistence."/nix/nodatacow".directories = inputs.lib.mkIf kvm.nodatacow
{ directory = "/var/lib/libvirt/images"; mode = "0711"; };
systemPackages = with inputs.pkgs; [ qemu_full win-spice guestfs-tools virt-manager ];
};
systemd =
{
services =
@@ -117,4 +123,8 @@ inputs:
networking.firewall.interfaces."virbr*".allowedUDPPorts = [ 53 67 ];
hardware.ksm.enable = true;
};
++ inputs.lib.optional (inputs.config.nixos.services.kvm != null)
{ directory = "/var/lib/libvirt/images"; mode = "0711"; };
}

View File

@@ -27,9 +27,7 @@ inputs:
{
hideMounts = true;
directories =
[{ directory = "/var/log/journal"; user = "root"; group = "systemd-journal"; mode = "u=rwx,g=rx+s,o=rx"; }]
++ inputs.lib.optional (inputs.config.nixos.services.kvm != null)
{ directory = "/var/lib/libvirt/images"; mode = "0711"; };
[{ directory = "/var/log/journal"; user = "root"; group = "systemd-journal"; mode = "u=rwx,g=rx+s,o=rx"; }];
};
}
# 挂载 /home/user