disko-install: improve error message if disk is not passed

This commit is contained in:
Jörg Thalheim 2024-03-05 14:27:01 +01:00 committed by mergify[bot]
parent 0d11aa8d64
commit cf185d687f
2 changed files with 15 additions and 13 deletions

View file

@ -78,17 +78,17 @@ parseArgs() {
exit 1
fi
case $2 in
format)
diskoAttr=diskoScript
;;
mount)
diskoAttr=mountScript
;;
*)
echo "Invalid mode: $2" >&2
echo "Valid modes are: format, mount" >&2
exit 1
;;
format)
diskoAttr=diskoScript
;;
mount)
diskoAttr=mountScript
;;
*)
echo "Invalid mode: $2" >&2
echo "Valid modes are: format, mount" >&2
exit 1
;;
esac
mode=$2
shift
@ -163,7 +163,7 @@ main() {
# shellcheck disable=SC2064
trap "cleanupMountPoint ${escapeMountPoint}" EXIT
IFS=$'\n' mapfile -t artifacts < <(nix-build "${libexec_dir}"/install-cli.nix \
outputs=$(nix-build "${libexec_dir}"/install-cli.nix \
"${nix_args[@]}" \
--no-out-link \
--impure \
@ -174,6 +174,8 @@ main() {
--arg diskMappings "$(serialiaseArrayToNix diskMappings)" \
-A installToplevel \
-A "$diskoAttr")
IFS=$'\n' mapfile -t artifacts <<<"$outputs"
nixos_system=${artifacts[0]}
disko_script=${artifacts[1]}

View file

@ -15,7 +15,7 @@ let
dev = if diskMappings ? ${name} then
diskMappings.${name}
else
throw "No device passed for disk '${name}'";
throw "No device passed for disk '${name}'. Pass `--disk ${name} /dev/name` via commandline";
in value // {
device = dev;
content = value.content // { device = dev; };