diff --git a/install.sh b/install.sh index 960be6e..b74736d 100644 --- a/install.sh +++ b/install.sh @@ -105,6 +105,29 @@ echo -e "${BLUE}Installing GNU Guix...${NC}" herd start cow-store /mnt -guix system init config.scm /mnt && reboot +install_guix() { + tmpfile=$(mktemp) + guix system init config.scm /mnt >(tee "$tmpfile") 2>&1 + exit_code=$? -echo -e "${RED}Installation has failed${NC}" + output=$(tail -n 3 "$tmpfile") + rm -f "$tmpfile" + + if [[ $exit_code -ne 0 && $output == *"died unexpectedly"* ]]; then + return 1 + else + return 0 + fi +} + +max_retries=5 +attempt=0 + +until install_guix; do + attempt=$((attempt + 1)) + if [[ $attempt -ge $max_retries ]]; then + echo -e "${RED}Installation has failed${NC}" + exit 1 + fi + echo -e "${BLUE}Trying installing GNU Guix again...${NC}" +done