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

View file

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