From b78adb6df8416abd2a22e176601f98410a646c36 Mon Sep 17 00:00:00 2001 From: Manuel Thalmann Date: Sat, 22 Jun 2024 22:51:11 +0200 Subject: [PATCH] Format partition only if newly created --- lib/modules/partition.nix | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/modules/partition.nix b/lib/modules/partition.nix index 4d2db02b..cb681890 100644 --- a/lib/modules/partition.nix +++ b/lib/modules/partition.nix @@ -123,6 +123,14 @@ create = lib.strings.concatLines [ (appendScript "${toString index}: \"$(${sizeOption})\" type=${mkType type}") + # Wait for partition to be detected + '' + while true; + do + [ -b ${partVar} ] && break; + done; + '' + "sudo ${formatScripts.${format}}" ]; fallback = '' @@ -132,17 +140,9 @@ fi ''; in [ - (if keepExisting then fallback else create) ''local diskPath="$(find -L /dev/disk/by-diskseq -samefile ${diskVar})"'' ''local ${partVarName}="$diskPath-part${toString index}"'' - # Wait for partition to be detected - '' - while true; - do - [ -b ${partVar} ] && break; - done; - '' - "sudo ${formatScripts.${format}}" + (if keepExisting then fallback else create) "sudo ${labelScripts.${format} label}" ]) partitions)