diff --git a/auto-install.sh b/auto-install.sh index 151464c..a329fc9 100755 --- a/auto-install.sh +++ b/auto-install.sh @@ -144,4 +144,29 @@ echo "-----" installusername=$(echo $USER) sed -i 's/username\s*=\s*"\([^"]*\)"/username = "'"$installusername"'"/' ./flake.nix -# TODO \ No newline at end of file +echo "${NOTE} generating the hardware configuration..." +attempts=0 +max_attempts=3 +hardware_file="./hosts/$hostName/hardware.nix" + +while [ $attempts -lt $max_attempts ]; do + sudo nixos-generate-config --show-hardware-config > "$hardware_file" 2>/dev/null + + if [ -f "$hardware_file" ]; then + echo "${OK} hardware configuration successfully generated" + break + else + echo "${WARN} failed to generate hardware configuration. attempt $(($attempts + 1)) of $max_attempts" + attempts=$(($attempts + 1)) + + # exit if this was the last attempt + if [ $attempts -eq $max_attempts ]; then + echo "${ERROR} unable to generate hardware configuration after $max_attempts attempts!" + exit 1 + fi + fi +done + +echo "-----" + +TODO \ No newline at end of file