Skip to content

Commit d32d150

Browse files
Enzimemergify[bot]
authored andcommitted
zpool: support updating zfsprops on root dataset
1 parent a9eeea3 commit d32d150

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

lib/types/zfs_fs.nix

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,12 @@
5252
description = "Metadata";
5353
};
5454

55+
_createFilesystem = lib.mkOption {
56+
internal = true;
57+
type = lib.types.bool;
58+
default = true;
59+
};
60+
5561
_create = diskoLib.mkCreateOption
5662
{
5763
inherit config options;
@@ -77,15 +83,20 @@
7783
in
7884
''
7985
if ! zfs get type ${config._name} >/dev/null 2>&1; then
80-
zfs create -up ${config._name} \
81-
${lib.concatStringsSep " " (lib.mapAttrsToList (n: v: "-o ${n}=${v}") (createOptions))}
86+
${if config._createFilesystem then ''
87+
zfs create -up ${config._name} \
88+
${lib.concatStringsSep " " (lib.mapAttrsToList (n: v: "-o ${n}=${v}") (createOptions))}
89+
'' else ''
90+
# don't create anything for root dataset of zpools
91+
true
92+
''}
8293
${lib.optionalString (updateOptions != {}) ''
8394
else
8495
zfs set -u ${lib.concatStringsSep " " (lib.mapAttrsToList (n: v: "${n}=${v}") updateOptions)} ${config._name}
8596
''}
8697
fi
8798
'';
88-
} // { readOnly = false; };
99+
};
89100

90101
_mount = diskoLib.mkMountOption {
91102
inherit config options;

lib/types/zpool.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ in
253253
config = {
254254
datasets."__root" = {
255255
_name = config.name;
256-
_create = "";
256+
_createFilesystem = false;
257257
type = "zfs_fs";
258258
mountpoint = config.mountpoint;
259259
options = config.rootFsOptions;

0 commit comments

Comments
 (0)