Skip to content

Commit

Permalink
zpool: support updating zfsprops on root dataset
Browse files Browse the repository at this point in the history
  • Loading branch information
Enzime authored and mergify[bot] committed Sep 17, 2024
1 parent a9eeea3 commit d32d150
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
17 changes: 14 additions & 3 deletions lib/types/zfs_fs.nix
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@
description = "Metadata";
};

_createFilesystem = lib.mkOption {
internal = true;
type = lib.types.bool;
default = true;
};

_create = diskoLib.mkCreateOption
{
inherit config options;
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion lib/types/zpool.nix
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ in
config = {
datasets."__root" = {
_name = config.name;
_create = "";
_createFilesystem = false;
type = "zfs_fs";
mountpoint = config.mountpoint;
options = config.rootFsOptions;
Expand Down

0 comments on commit d32d150

Please sign in to comment.