From 68368b943a5b3d9041dd2a30ebbb1a96910aedf8 Mon Sep 17 00:00:00 2001 From: shynd Date: Thu, 20 Feb 2025 11:32:13 +0100 Subject: [PATCH] auto-install script --- auto-install.sh | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) 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