mirror of
https://github.com/nix-community/disko
synced 2024-11-12 23:27:07 +00:00
tidy: move relevant variables and format script block
This commit is contained in:
parent
b2a106f8ed
commit
6bebcc728e
1 changed files with 85 additions and 80 deletions
|
@ -7,13 +7,6 @@ let
|
|||
"raidz2"
|
||||
"raidz3"
|
||||
];
|
||||
format_output = (mode: members: ''
|
||||
entries+=("${mode}=${
|
||||
lib.concatMapStringsSep " "
|
||||
(d: "/dev/disk/by-partlabel/disk-${d}-zfs") members
|
||||
}")
|
||||
'');
|
||||
format_vdev = (vdev: format_output vdev.mode vdev.members);
|
||||
in
|
||||
{
|
||||
options = {
|
||||
|
@ -119,7 +112,18 @@ in
|
|||
};
|
||||
_create = diskoLib.mkCreateOption {
|
||||
inherit config options;
|
||||
default = ''
|
||||
default =
|
||||
let
|
||||
format_output = (mode: members: ''
|
||||
entries+=("${mode}=${
|
||||
lib.concatMapStringsSep " "
|
||||
(d: "/dev/disk/by-partlabel/disk-${d}-zfs") members
|
||||
}")
|
||||
'');
|
||||
format_vdev = (vdev: format_output vdev.mode vdev.members);
|
||||
hasTopology = config.topology != null;
|
||||
in
|
||||
''
|
||||
readarray -t zfs_devices < <(cat "$disko_devices_dir"/zfs_${config.name})
|
||||
# Try importing the pool without mounting anything if it exists.
|
||||
# This allows us to set mounpoints.
|
||||
|
@ -147,7 +151,7 @@ in
|
|||
# For shell check
|
||||
mode="${config.mode}"
|
||||
if [ $mode != "prescribed" ]; then
|
||||
${if config.topology == null then
|
||||
${if hasTopology then
|
||||
''topology="${config.mode} \"''${zfs_devices}\""''
|
||||
else
|
||||
''
|
||||
|
@ -157,10 +161,11 @@ in
|
|||
}
|
||||
else
|
||||
entries=()
|
||||
${lib.concatMapStrings format_vdev config.topology.vdev}
|
||||
${lib.optionalString (config.topology.special != null)
|
||||
${lib.optionalString (hasTopology && config.topology.vdev != null)
|
||||
(lib.concatMapStrings format_vdev config.topology.vdev)}
|
||||
${lib.optionalString (hasTopology && config.topology.special != null)
|
||||
(format_output "special ${config.topology.special.mode}" config.topology.special.members)}
|
||||
${lib.optionalString (config.topology.cache != null)
|
||||
${lib.optionalString (hasTopology && config.topology.cache != null)
|
||||
(format_output "cache" [config.topology.cache])}
|
||||
all_devices=()
|
||||
for line in "''${entries[@]}"; do
|
||||
|
|
Loading…
Reference in a new issue