zpool: support updating zfsprops on root dataset

This commit is contained in:
Michael Hoang 2024-09-15 16:37:22 +07:00 committed by mergify[bot]
parent a9eeea3379
commit d32d1504c7
2 changed files with 15 additions and 4 deletions

View file

@ -52,6 +52,12 @@
description = "Metadata";
};
_createFilesystem = lib.mkOption {
internal = true;
type = lib.types.bool;
default = true;
};
_create = diskoLib.mkCreateOption
{
inherit config options;
@ -77,15 +83,20 @@
in
''
if ! zfs get type ${config._name} >/dev/null 2>&1; then
zfs create -up ${config._name} \
${lib.concatStringsSep " " (lib.mapAttrsToList (n: v: "-o ${n}=${v}") (createOptions))}
${if config._createFilesystem then ''
zfs create -up ${config._name} \
${lib.concatStringsSep " " (lib.mapAttrsToList (n: v: "-o ${n}=${v}") (createOptions))}
'' else ''
# don't create anything for root dataset of zpools
true
''}
${lib.optionalString (updateOptions != {}) ''
else
zfs set -u ${lib.concatStringsSep " " (lib.mapAttrsToList (n: v: "${n}=${v}") updateOptions)} ${config._name}
''}
fi
'';
} // { readOnly = false; };
};
_mount = diskoLib.mkMountOption {
inherit config options;

View file

@ -253,7 +253,7 @@ in
config = {
datasets."__root" = {
_name = config.name;
_create = "";
_createFilesystem = false;
type = "zfs_fs";
mountpoint = config.mountpoint;
options = config.rootFsOptions;