From 98443550483c3f82240c2de40a4bfeb0c1d62626 Mon Sep 17 00:00:00 2001 From: Manuel Thalmann Date: Wed, 26 Jun 2024 18:13:07 +0200 Subject: [PATCH] Ask for a different disk if not found --- lib/modules/partition.nix | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/lib/modules/partition.nix b/lib/modules/partition.nix index 24678436..0ab587ea 100644 --- a/lib/modules/partition.nix +++ b/lib/modules/partition.nix @@ -161,8 +161,26 @@ if osDisk && config.devicePath == null then '' ${diskSelector} '' - else - "local ${diskVarName}=${config.devicePath}"} + else '' + local ${diskVarName}=${config.devicePath} + ${if osDisk then '' + . ${./../../../scripts/Common/Scripts/is-truthy.sh} + if [ ! -b ${diskVar} ]; then + function fallback() { + echo "Couldn't find the specified disk \"${diskVar}\"." + echo "Do you want to install the OS on another disk?" + local answer + read answer + if isTruthy "$answer"; then + ${diskSelector} + else + exit 1 + fi + } + fallback; + fi + '' else ""} + ''} ${if (!config.wipe) then cleanup else ""}