Skip to content

Commit

Permalink
Merge pull request #211 from SuperSandro2000/zpool-R
Browse files Browse the repository at this point in the history
zpool: add option to mount zpool not at /
  • Loading branch information
Lassulus committed Apr 29, 2023
2 parents 77a54e5 + e78e5b1 commit 617c77a
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions types/zpool.nix
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,17 @@
default = [ "defaults" ];
description = "Options to pass to mount";
};
mountRoot = lib.mkOption {
type = lib.types.str;
default = "/";
example = "/mnt";
description = ''
The root location where the zpool should be mounted.
Note:
Leaving this at the default "/" might break your live system.
'';
};
datasets = lib.mkOption {
type = lib.types.attrsOf (diskoLib.subType { inherit (subTypes) zfs_fs zfs_volume; });
# type = lib.types.attrsOf subTypes.zfs_fs;
Expand All @@ -55,7 +66,7 @@
default = _: ''
readarray -t zfs_devices < <(cat "$disko_devices_dir"/zfs_${config.name})
zpool create ${config.name} \
${config.mode} \
-R ${config.mountRoot} ${config.mode} \
${lib.concatStringsSep " " (lib.mapAttrsToList (n: v: "-o ${n}=${v}") config.options)} \
${lib.concatStringsSep " " (lib.mapAttrsToList (n: v: "-O ${n}=${v}") config.rootFsOptions)} \
"''${zfs_devices[@]}"
Expand All @@ -70,7 +81,8 @@
in
{
dev = ''
zpool list '${config.name}' >/dev/null 2>/dev/null || zpool import '${config.name}'
zpool list '${config.name}' >/dev/null 2>/dev/null || \
zpool import -R ${config.mountRoot} '${config.name}'
${lib.concatMapStrings (x: x.dev or "") (lib.attrValues datasetMounts)}
'';
fs = (datasetMounts.fs or {}) // lib.optionalAttrs (config.mountpoint != null) {
Expand Down

0 comments on commit 617c77a

Please sign in to comment.