diff --git a/lib/modules/partition/disks.nix b/lib/modules/partition/disks.nix index 1bc0f29f..4c19cf6e 100644 --- a/lib/modules/partition/disks.nix +++ b/lib/modules/partition/disks.nix @@ -137,6 +137,7 @@ create = lib.strings.concatLines [ (appendScript "${toString index}: \"$(${sizeOption})\" type=${mkType type}") # Wait for partition to be detected + ''echo "Waiting for ${partVar} to appear..."'' '' while true; do @@ -326,14 +327,23 @@ partitions = (builtins.concatMap (_: (builtins.attrValues _.partitions)) disks); mountScript = lib.strings.concatLines ( - builtins.map - (_: builtins.concatStringsSep " " [ - "sudo" - "mount" - "--mkdir" - (builtins.concatStringsSep " " (builtins.map (_: "-o ${_}") _.mountOptions)) - (partPath _) - (normalizePath "/${rootDir}/${_.mountPoint}") + builtins.concatMap + (_: [ + ''echo "Waiting for "${lib.strings.escapeShellArg (partPath _)}" to appear..."'' + '' + while true; + do + [ -b ${lib.strings.escapeShellArg (partPath _)} ] && break + done + '' + (builtins.concatStringsSep " " [ + "sudo" + "mount" + "--mkdir" + (builtins.concatStringsSep " " (builtins.map (_: "-o ${_}") _.mountOptions)) + (partPath _) + (normalizePath "/${rootDir}/${_.mountPoint}") + ]) ]) (lib.lists.sortOn (_: normalizePath "/${_.mountPoint}")