2024-02-18 06:06:56 +01:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
if [ -n "$(cat /etc/os-release | grep -i nixos)" ]; then
|
2024-03-01 05:38:55 +01:00
|
|
|
echo "Verified this is NixOS."
|
2024-02-18 06:06:56 +01:00
|
|
|
echo "-----"
|
|
|
|
else
|
|
|
|
echo "This is not NixOS or the distribution information is not available."
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
2024-02-19 10:47:42 +01:00
|
|
|
if command -v git &> /dev/null; then
|
|
|
|
echo "Git is installed, continuing with installation."
|
|
|
|
else
|
|
|
|
echo "Git is not installed. Please install Git and try again."
|
|
|
|
echo "Example: nix-shell -p git"
|
2024-04-13 08:25:33 +02:00
|
|
|
exit
|
2024-02-19 10:47:42 +01:00
|
|
|
fi
|
2024-02-18 06:06:56 +01:00
|
|
|
|
|
|
|
echo "-----"
|
|
|
|
|
2024-03-01 05:38:55 +01:00
|
|
|
echo "Ensure In Home Directory"
|
2024-04-04 03:26:15 +02:00
|
|
|
cd
|
2024-03-01 05:38:55 +01:00
|
|
|
|
|
|
|
echo "-----"
|
|
|
|
|
2024-04-04 03:16:41 +02:00
|
|
|
read -p "Enter Your New Hostname: [ hyprnix ] " hostName
|
|
|
|
if [ -z "$hostName" ]; then
|
|
|
|
hostName="hyprnix"
|
2024-04-04 02:24:49 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
echo "-----"
|
|
|
|
|
|
|
|
backupname=$(date "+%Y-%m-%d-%H-%M-%S")
|
|
|
|
if [ -d "zaneyos" ]; then
|
|
|
|
echo "ZaneyOS exists, backing up to .config/zaneyos-backups folder."
|
|
|
|
if [ -d ".config/zaneyos-backups" ]; then
|
|
|
|
echo "Moving current version of ZaneyOS to backups folder."
|
|
|
|
mv $HOME/zaneyos .config/zaneyos-backups/$backupname
|
|
|
|
sleep 1
|
2024-03-02 22:09:30 +01:00
|
|
|
else
|
2024-04-04 02:24:49 +02:00
|
|
|
echo "Creating the backups folder & moving ZaneyOS to it."
|
|
|
|
mkdir -p .config/zaneyos-backups
|
|
|
|
mv $HOME/zaneyos .config/zaneyos-backups/$backupname
|
|
|
|
sleep 1
|
2024-03-02 22:09:30 +01:00
|
|
|
fi
|
2024-04-04 02:24:49 +02:00
|
|
|
else
|
|
|
|
echo "Thank you for choosing ZaneyOS."
|
|
|
|
echo "I hope you find your time here enjoyable!"
|
2024-03-01 05:38:55 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
echo "-----"
|
|
|
|
|
2024-04-04 03:26:15 +02:00
|
|
|
echo "Cloning & Entering ZaneyOS Repository"
|
|
|
|
git clone https://gitlab.com/zaney/zaneyos.git
|
|
|
|
cd zaneyos
|
|
|
|
mkdir hosts/$hostName
|
|
|
|
cp hosts/default/*.nix hosts/$hostName
|
2024-04-04 04:29:41 +02:00
|
|
|
git add .
|
2024-04-04 03:26:15 +02:00
|
|
|
sed -i "/^\s*setHostname[[:space:]]*=[[:space:]]*\"/s/\"\(.*\)\"/\"$hostName\"/" ./hosts/$hostName/options.nix
|
2024-04-18 06:15:37 +02:00
|
|
|
sed -i "/^\s*host[[:space:]]*=[[:space:]]*\"/s/\"\(.*\)\"/\"$hostName\"/" ./flake.nix
|
2024-04-04 03:26:15 +02:00
|
|
|
|
|
|
|
echo "-----"
|
|
|
|
|
2024-03-01 23:18:30 +01:00
|
|
|
echo "Default options are in brackets []"
|
|
|
|
echo "Just press enter to select the default"
|
|
|
|
sleep 2
|
|
|
|
|
|
|
|
echo "-----"
|
|
|
|
|
|
|
|
installusername=$(echo $USER)
|
2024-03-01 23:49:21 +01:00
|
|
|
read -p "Enter Your Username: [ $installusername ] " userName
|
2024-03-01 23:18:30 +01:00
|
|
|
if [ -z "$userName" ]; then
|
|
|
|
userName=$(echo $USER)
|
|
|
|
else
|
2024-03-02 22:09:30 +01:00
|
|
|
if [ $installusername != $userName ]; then
|
|
|
|
echo "This will create a hashedPassword for the new user in the options file."
|
|
|
|
while true; do
|
2024-03-02 22:29:19 +01:00
|
|
|
read -s -p "Enter New User Password: " newPass
|
|
|
|
read -s -p "Enter New User Password Again: " newPass2
|
2024-03-02 22:09:30 +01:00
|
|
|
if [ $newPass == $newPass2 ]; then
|
|
|
|
echo "Passwords Match. Setting password."
|
|
|
|
userPassword=$(mkpasswd -m sha-512 $newPass)
|
|
|
|
escaped_userPassword=$(echo "$userPassword" | sed 's/\//\\\//g')
|
|
|
|
sed -i "/^\s*hashedPassword[[:space:]]*=[[:space:]]*\"/s#\"\(.*\)\"#\"$escaped_userPassword\"#" ./system.nix
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
fi
|
2024-03-01 23:18:30 +01:00
|
|
|
fi
|
2024-04-04 03:16:41 +02:00
|
|
|
sed -i "/^\s*setUsername[[:space:]]*=[[:space:]]*\"/s/\"\(.*\)\"/\"$userName\"/" ./hosts/$hostName/options.nix
|
2024-02-18 06:06:56 +01:00
|
|
|
|
|
|
|
echo "-----"
|
|
|
|
|
2024-02-19 10:53:07 +01:00
|
|
|
echo "Generating The Hardware Configuration"
|
2024-04-04 03:16:41 +02:00
|
|
|
sudo nixos-generate-config --show-hardware-config > ./hosts/$hostName/hardware.nix
|
2024-02-18 06:06:56 +01:00
|
|
|
|
2024-02-19 10:53:07 +01:00
|
|
|
echo "-----"
|
|
|
|
|
2024-04-18 23:00:04 +02:00
|
|
|
echo "Setting Required Nix Settings & Committing Changes"
|
|
|
|
git add .
|
2024-04-04 04:29:41 +02:00
|
|
|
git commit -am "Add new hosts folder and all the new settings"
|
2024-04-18 23:00:04 +02:00
|
|
|
NIX_CONFIG="experimental-features = nix-command flakes"
|
2024-03-02 22:09:30 +01:00
|
|
|
|
|
|
|
if [ $userName != $installusername ]; then
|
|
|
|
cd
|
|
|
|
cp -r zaneyos /home/$userName/
|
|
|
|
sudo chown -R $userName:users /home/$userName/zaneyos
|
|
|
|
echo "Ensuring ZaneyOS repository is in your users HOME directory."
|
|
|
|
fi
|
2024-03-02 22:25:28 +01:00
|
|
|
|
|
|
|
echo "-----"
|
|
|
|
|
2024-04-18 23:00:04 +02:00
|
|
|
echo "ZaneyOS Has Been Setup"
|
|
|
|
echo "Make Sure To Change Your Options In hosts/<yourhostname>"
|
|
|
|
echo "To Install Run: sudo nixos-rebuild switch --flake .#<yourhostname>"
|