auto-install script
This commit is contained in:
		
							parent
							
								
									b4be2a3f1f
								
							
						
					
					
						commit
						68368b943a
					
				| 
						 | 
				
			
			@ -144,4 +144,29 @@ echo "-----"
 | 
			
		|||
installusername=$(echo $USER)
 | 
			
		||||
sed -i 's/username\s*=\s*"\([^"]*\)"/username = "'"$installusername"'"/' ./flake.nix
 | 
			
		||||
 | 
			
		||||
# TODO
 | 
			
		||||
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
 | 
			
		||||
		Loading…
	
		Reference in New Issue