Format partition only if newly created

This commit is contained in:
Manuel Thalmann 2024-06-22 22:51:11 +02:00
parent 1f24914de4
commit d919d2b6b9

View file

@ -123,6 +123,14 @@
create = lib.strings.concatLines [ create = lib.strings.concatLines [
(appendScript "${toString index}: \"$(${sizeOption})\" type=${mkType type}") (appendScript "${toString index}: \"$(${sizeOption})\" type=${mkType type}")
# Wait for partition to be detected
''
while true;
do
[ -b ${partVar} ] && break;
done;
''
"sudo ${formatScripts.${format}}"
]; ];
fallback = '' fallback = ''
@ -132,17 +140,9 @@
fi fi
''; '';
in [ in [
(if keepExisting then fallback else create)
''local diskPath="$(find -L /dev/disk/by-diskseq -samefile ${diskVar})"'' ''local diskPath="$(find -L /dev/disk/by-diskseq -samefile ${diskVar})"''
''local ${partVarName}="$diskPath-part${toString index}"'' ''local ${partVarName}="$diskPath-part${toString index}"''
# Wait for partition to be detected (if keepExisting then fallback else create)
''
while true;
do
[ -b ${partVar} ] && break;
done;
''
"sudo ${formatScripts.${format}}"
"sudo ${labelScripts.${format} label}" "sudo ${labelScripts.${format} label}"
]) ])
partitions) partitions)