mirror of
https://github.com/nix-community/disko.git
synced 2024-09-19 18:47:16 +03:00
zpool: deduplicate root mount option
This commit is contained in:
parent
9191c0ed48
commit
b7f3ee8e14
@ -37,17 +37,6 @@
|
|||||||
default = [ "defaults" ];
|
default = [ "defaults" ];
|
||||||
description = "Options to pass to mount";
|
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 {
|
datasets = lib.mkOption {
|
||||||
type = lib.types.attrsOf (diskoLib.subType {
|
type = lib.types.attrsOf (diskoLib.subType {
|
||||||
types = { inherit (diskoLib.types) zfs_fs zfs_volume; };
|
types = { inherit (diskoLib.types) zfs_fs zfs_volume; };
|
||||||
@ -68,7 +57,7 @@
|
|||||||
default = ''
|
default = ''
|
||||||
readarray -t zfs_devices < <(cat "$disko_devices_dir"/zfs_${config.name})
|
readarray -t zfs_devices < <(cat "$disko_devices_dir"/zfs_${config.name})
|
||||||
zpool create -f ${config.name} \
|
zpool create -f ${config.name} \
|
||||||
-R ${config.mountRoot} ${config.mode} \
|
-R ${rootMountPoint} ${config.mode} \
|
||||||
${lib.concatStringsSep " " (lib.mapAttrsToList (n: v: "-o ${n}=${v}") config.options)} \
|
${lib.concatStringsSep " " (lib.mapAttrsToList (n: v: "-o ${n}=${v}") config.options)} \
|
||||||
${lib.concatStringsSep " " (lib.mapAttrsToList (n: v: "-O ${n}=${v}") config.rootFsOptions)} \
|
${lib.concatStringsSep " " (lib.mapAttrsToList (n: v: "-O ${n}=${v}") config.rootFsOptions)} \
|
||||||
"''${zfs_devices[@]}"
|
"''${zfs_devices[@]}"
|
||||||
@ -84,7 +73,7 @@
|
|||||||
{
|
{
|
||||||
dev = ''
|
dev = ''
|
||||||
zpool list '${config.name}' >/dev/null 2>/dev/null ||
|
zpool list '${config.name}' >/dev/null 2>/dev/null ||
|
||||||
zpool import -l -R ${config.mountRoot} '${config.name}'
|
zpool import -l -R ${rootMountPoint} '${config.name}'
|
||||||
${lib.concatMapStrings (x: x.dev or "") (lib.attrValues datasetMounts)}
|
${lib.concatMapStrings (x: x.dev or "") (lib.attrValues datasetMounts)}
|
||||||
'';
|
'';
|
||||||
fs = (datasetMounts.fs or { }) // lib.optionalAttrs (config.mountpoint != null) {
|
fs = (datasetMounts.fs or { }) // lib.optionalAttrs (config.mountpoint != null) {
|
||||||
|
Loading…
Reference in New Issue
Block a user