diff --git a/lib/default.nix b/lib/default.nix index f9ddd35e..98a8f368 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -382,15 +382,24 @@ rec { log_error "/mnt is not a mountpoint or resides on a /tmpfs. The installation cannot succeed. Exiting." exit 1 fi - ${optionalString createSecureBootKeys createSecureBootKeysScript} - box_message "Burning the image on ${mainDisk}..." - ${installProcedureScript config} - ${optionalString enrollSecureBootKeys secureBootEnrollmentScript} - ${optionalString (preprovisionOptions.tpm2HostKeys or false) tpm2ProvisionScript} - ${optionalString (preprovisionOptions.ageHostKeys or false) ageKeysProvisionScript} - ${postInstallScript} - lsblk - log_info "Installation is complete. You can now reboot in the installed system." + ( + set -e + ${optionalString createSecureBootKeys createSecureBootKeysScript} + box_message "Burning the image on ${mainDisk}..." + ${installProcedureScript config} + ${optionalString enrollSecureBootKeys secureBootEnrollmentScript} + ${optionalString (preprovisionOptions.tpm2HostKeys or false) tpm2ProvisionScript} + ${optionalString (preprovisionOptions.ageHostKeys or false) ageKeysProvisionScript} + ${postInstallScript} + ) + INSTALL_FAILED=$? + if [ "$INSTALL_FAILED" -ne 0 ]; then + log_error "Installation failed." + box_message "Installation aborted: see /tmp/install.log for details." + else + lsblk + log_info "Installation is complete. You can now reboot in the installed system." + fi if [ -f "$INSTALL_LOG" ]; then mkdir -p /mnt/var/log @@ -398,6 +407,10 @@ rec { log_info "Install log saved to /var/log/securix-install.log on the target system." fi + if [ "$INSTALL_FAILED" -ne 0 ]; then + exit 1 + fi + '') ]; }