modules.services.nixvirt: allow images from anywhere

This commit is contained in:
2025-09-07 08:19:24 +08:00
parent 9830bb15dc
commit 23efd75504

View File

@@ -21,7 +21,7 @@ inputs:
storage = storage =
{ {
name = mkOption { type = types.nonEmptyStr; default = submoduleInputs.config._module.args.name; }; name = mkOption { type = types.nonEmptyStr; default = submoduleInputs.config._module.args.name; };
nodatacow = mkOption { type = types.bool; default = false; }; mountFrom = mkOption { type = types.nullOr types.nonEmptyStr; default = null; };
iso = mkOption { type = types.nullOr types.nonEmptyStr; default = null; }; iso = mkOption { type = types.nullOr types.nonEmptyStr; default = null; };
}; };
memory = memory =
@@ -199,8 +199,12 @@ inputs:
type = "file"; type = "file";
device = "disk"; device = "disk";
driver = { name = "qemu"; type = "raw"; cache = "writeback"; discard = "unmap"; }; driver = { name = "qemu"; type = "raw"; cache = "writeback"; discard = "unmap"; };
source.file = "${if v.storage.nodatacow then "/nix/nodatacow" else ""}/var/lib/libvirt/images/" source.file = builtins.concatStringsSep ""
+ "${v.storage.name}.img"; [
(if (v.storage.mountFrom != null) then "/nix/${v.storage.mountFrom}" else "")
"/var/lib/libvirt/images/"
"${v.storage.name}.img"
];
target = { dev = "vda"; bus = "virtio"; }; target = { dev = "vda"; bus = "virtio"; };
boot.order = 1; boot.order = 1;
} }