update isntall script to chose host

This commit is contained in:
Frost-Phoenix 2024-04-16 21:50:23 +02:00
parent efa5f58745
commit 3298c6a47f

View file

@ -62,6 +62,25 @@ set_username() {
sed -i -e "s/${CURRENT_USERNAME}/${username}/g" ./modules/home/audacious/config
}
get_host() {
echo -en "Chose a ${GREEN}host${NORMAL}, either [${YELLOW}D${NORMAL}]esktop or [${YELLOW}L${NORMAL}]aptop: "
read -n 1 -r
echo
if [[ $REPLY =~ ^[Dd]$ ]]; then
HOST='desktop'
elif [[ $REPLY =~ ^[Ll]$ ]]; then
HOST='laptop'
else
echo "Invalid choice. Please select either 'D' for desktop or 'L' for laptop."
exit 1
fi
echo -en "$NORMAL"
echo -en "Use the$YELLOW "$HOST"$NORMAL ${GREEN}host${NORMAL} ? "
comfirm
}
install() {
echo -e "\n${RED}START INSTALL PHASE${NORMAL}\n"
sleep 0.2
@ -83,8 +102,8 @@ install() {
sleep 0.2
# Get the hardware configuration
echo -e "Copying ${MAGENTA}/etc/nixos/hardware-configuration.nix${NORMAL} to ${MAGENTA}./hosts/nixos/${NORMAL}\n"
cp /etc/nixos/hardware-configuration.nix hosts/desktop/hardware-configuration.nix
echo -e "Copying ${MAGENTA}/etc/nixos/hardware-configuration.nix${NORMAL} to ${MAGENTA}./hosts/${HOST}/${NORMAL}\n"
cp /etc/nixos/hardware-configuration.nix hosts/${HOST}/hardware-configuration.nix
sleep 0.2
# Last Confirmation
@ -93,7 +112,7 @@ install() {
# Build the system (flakes + home manager)
echo -e "\nBuilding the system...\n"
sudo nixos-rebuild switch --flake .#desktop
sudo nixos-rebuild switch --flake .#${HOST}
}
main() {
@ -103,6 +122,7 @@ main() {
get_username
set_username
get_host
install
}