Feature(zfs_volume); Add internal option for fully qualified zfs path

This commit is contained in:
Bert Proesmans
2026-05-29 08:41:07 +02:00
committed by Michael Hoang
parent 36c1d04e85
commit 03e19b4f67
+8 -2
View File
@@ -13,6 +13,12 @@
default = config._module.args.name; default = config._module.args.name;
description = "Name of the dataset"; description = "Name of the dataset";
}; };
_name = lib.mkOption {
type = lib.types.str;
default = "${config._parent.name}/${config.name}";
internal = true;
description = "Fully quantified name for dataset";
};
type = lib.mkOption { type = lib.mkOption {
type = lib.types.enum [ "zfs_volume" ]; type = lib.types.enum [ "zfs_volume" ];
default = "zfs_volume"; default = "zfs_volume";
@@ -61,8 +67,8 @@
_create = diskoLib.mkCreateOption { _create = diskoLib.mkCreateOption {
inherit config options; inherit config options;
default = '' default = ''
if ! zfs get type "${config._parent.name}/${config.name}" >/dev/null 2>&1; then if ! zfs get type "${config._name}" >/dev/null 2>&1; then
zfs create "${config._parent.name}/${config.name}" \ zfs create "${config._name}" \
${ ${
lib.concatStringsSep " " ( lib.concatStringsSep " " (
lib.mapAttrsToList (n: v: "-o ${n}=${lib.escapeShellArg v}") config.options lib.mapAttrsToList (n: v: "-o ${n}=${lib.escapeShellArg v}") config.options