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"
|
|
|
|
exit 1
|
|
|
|
fi
|
2024-02-18 06:06:56 +01:00
|
|
|
|
|
|
|
echo "-----"
|
|
|
|
|
2024-03-01 05:38:55 +01:00
|
|
|
echo "Ensure In Home Directory"
|
2024-02-18 06:06:56 +01:00
|
|
|
cd
|
2024-03-01 05:38:55 +01:00
|
|
|
|
|
|
|
echo "-----"
|
|
|
|
|
2024-03-02 22:09:30 +01:00
|
|
|
# Check For Persistence. Backing up current flake files
|
|
|
|
# with it enabled is not yet implemented.
|
|
|
|
persistState=$(cat zaneyos/hardware.nix | grep persistence | wc -l)
|
|
|
|
if [ $persistState -eq 0 ]; then
|
|
|
|
backupname=$(date "+%Y-%m-%d-%H-%M-%S")
|
|
|
|
if [ -d "zaneyos" ]; then
|
2024-03-01 05:38:55 +01:00
|
|
|
echo "ZaneyOS exists, backing up to .config/zaneyos-backups folder."
|
|
|
|
if [ -d ".config/zaneyos-backups" ]; then
|
2024-03-01 05:54:39 +01:00
|
|
|
echo "Moving current version of ZaneyOS to backups folder."
|
2024-03-01 06:22:35 +01:00
|
|
|
mv $HOME/zaneyos .config/zaneyos-backups/$backupname
|
2024-03-01 05:38:55 +01:00
|
|
|
sleep 1
|
|
|
|
else
|
2024-03-01 05:54:39 +01:00
|
|
|
echo "Creating the backups folder & moving ZaneyOS to it."
|
2024-03-01 23:35:59 +01:00
|
|
|
mkdir -p .config/zaneyos-backups
|
2024-03-01 06:22:35 +01:00
|
|
|
mv $HOME/zaneyos .config/zaneyos-backups/$backupname
|
2024-03-01 05:38:55 +01:00
|
|
|
sleep 1
|
|
|
|
fi
|
2024-03-02 22:09:30 +01:00
|
|
|
else
|
2024-03-01 05:38:55 +01:00
|
|
|
echo "Thank you for choosing ZaneyOS."
|
|
|
|
echo "I hope you find your time here enjoyable!"
|
2024-03-02 22:09:30 +01:00
|
|
|
fi
|
2024-03-01 05:38:55 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
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 "-----"
|
|
|
|
|
2024-02-18 06:06:56 +01:00
|
|
|
echo "Cloning & Entering ZaneyOS Repository"
|
|
|
|
git clone https://gitlab.com/zaney/zaneyos.git
|
|
|
|
cd zaneyos
|
|
|
|
|
2024-02-19 10:53:07 +01:00
|
|
|
echo "-----"
|
2024-02-18 06:06:56 +01:00
|
|
|
|
2024-03-01 23:18:30 +01:00
|
|
|
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
|
|
|
|
read -p "Enter New User Password: " newPass
|
|
|
|
read -p "Enter New User Password Again: " newPass2
|
|
|
|
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-02-18 06:06:56 +01:00
|
|
|
sed -i "/^\s*username[[:space:]]*=[[:space:]]*\"/s/\"\(.*\)\"/\"$userName\"/" ./options.nix
|
|
|
|
|
|
|
|
echo "-----"
|
|
|
|
|
2024-03-01 23:49:21 +01:00
|
|
|
read -p "Enter Your New Hostname: [ hyprnix ] " hostName
|
2024-03-01 23:18:30 +01:00
|
|
|
if [ -z "$hostName" ]; then
|
|
|
|
hostName="hyprnix"
|
|
|
|
fi
|
2024-02-18 06:06:56 +01:00
|
|
|
sed -i "/^\s*hostname[[:space:]]*=[[:space:]]*\"/s/\"\(.*\)\"/\"$hostName\"/" ./options.nix
|
|
|
|
|
|
|
|
echo "-----"
|
|
|
|
|
2024-03-02 22:09:30 +01:00
|
|
|
read -p "Enter Your New Git Username: [ John Smith ] " gitUserName
|
|
|
|
if [ -z "$gitUserName" ]; then
|
|
|
|
gitUserName="John Smith"
|
|
|
|
fi
|
2024-02-18 06:06:56 +01:00
|
|
|
sed -i "/^\s*gitUsername[[:space:]]*=[[:space:]]*\"/s/\"\(.*\)\"/\"$gitUserName\"/" ./options.nix
|
|
|
|
|
|
|
|
echo "-----"
|
|
|
|
|
2024-03-02 22:09:30 +01:00
|
|
|
read -p "Enter Your New Git Email: [ johnsmith@gmail.com ] " gitEmail
|
|
|
|
if [ -z "$gitEmail" ]; then
|
|
|
|
gitEmail="johnsmith@gmail.com"
|
|
|
|
fi
|
2024-02-18 06:06:56 +01:00
|
|
|
sed -i "/^\s*gitEmail[[:space:]]*=[[:space:]]*\"/s/\"\(.*\)\"/\"$gitEmail\"/" ./options.nix
|
|
|
|
|
|
|
|
echo "-----"
|
|
|
|
|
2024-03-01 23:18:30 +01:00
|
|
|
read -p "Enter Your Locale: [ en_US.UTF-8 ] " locale
|
|
|
|
if [ -z "$locale" ]; then
|
|
|
|
locale="en_US.UTF-8"
|
|
|
|
fi
|
2024-02-18 06:06:56 +01:00
|
|
|
sed -i "/^\s*theLocale[[:space:]]*=[[:space:]]*\"/s/\"\(.*\)\"/\"$locale\"/" ./options.nix
|
|
|
|
|
|
|
|
echo "-----"
|
|
|
|
|
2024-03-01 23:18:30 +01:00
|
|
|
read -p "Enter Your Keyboard Layout: [ us ] " kbdLayout
|
|
|
|
if [ -z "$kbdLayout" ]; then
|
|
|
|
kbdLayout="us"
|
|
|
|
fi
|
2024-02-18 06:06:56 +01:00
|
|
|
sed -i "/^\s*theKBDLayout[[:space:]]*=[[:space:]]*\"/s/\"\(.*\)\"/\"$kbdLayout\"/" ./options.nix
|
|
|
|
|
|
|
|
echo "-----"
|
|
|
|
|
2024-03-01 23:18:30 +01:00
|
|
|
read -p "Enter Your Timezone: [ America/New_York ] " timezone
|
|
|
|
if [ -z "$timezone" ]; then
|
|
|
|
timezone="America/New_York"
|
|
|
|
fi
|
2024-02-18 08:29:24 +01:00
|
|
|
escaped_timezone=$(echo "$timezone" | sed 's/\//\\\//g')
|
|
|
|
sed -i "/^\s*theTimezone[[:space:]]*=[[:space:]]*\"/s#\"\(.*\)\"#\"$escaped_timezone\"#" ./options.nix
|
2024-02-18 06:06:56 +01:00
|
|
|
|
|
|
|
echo "-----"
|
|
|
|
|
2024-03-01 23:18:30 +01:00
|
|
|
read -p "Enter Your Desired Browser: [ firefox ] " browser
|
|
|
|
if [ -z "$browser" ]; then
|
|
|
|
browser="firefox"
|
|
|
|
fi
|
2024-03-01 05:38:55 +01:00
|
|
|
sed -i "/^\s*browser[[:space:]]*=[[:space:]]*\"/s/\"\(.*\)\"/\"$browser\"/" ./options.nix
|
|
|
|
|
|
|
|
echo "-----"
|
|
|
|
|
2024-03-01 23:18:30 +01:00
|
|
|
read -p "Enable Animated Borders: [ false ] " animBorder
|
|
|
|
user_input_lower=$(echo "$animBorder" | tr '[:upper:]' '[:lower:]')
|
|
|
|
case $user_input_lower in
|
|
|
|
y|yes|true|t|enable)
|
|
|
|
animBorder="true"
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
animBorder="false"
|
|
|
|
;;
|
|
|
|
esac
|
2024-03-01 05:38:55 +01:00
|
|
|
sed -i "/^\s*borderAnim[[:space:]]*=[[:space:]]*\"/s/\"\(.*\)\"/\"$animBorder\"/" ./options.nix
|
|
|
|
|
|
|
|
echo "-----"
|
|
|
|
|
2024-03-01 23:18:30 +01:00
|
|
|
read -p "Install Kdenlive [ false ] : " kdenlive
|
|
|
|
user_input_lower=$(echo "$kdenlive" | tr '[:upper:]' '[:lower:]')
|
|
|
|
case $user_input_lower in
|
|
|
|
y|yes|true|t|enable)
|
|
|
|
kdenlive="true"
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
kdenlive="false"
|
|
|
|
;;
|
|
|
|
esac
|
2024-03-01 05:38:55 +01:00
|
|
|
sed -i "/^\s*kdenlive[[:space:]]*=[[:space:]]*\"/s/\"\(.*\)\"/\"$kdenlive\"/" ./options.nix
|
|
|
|
|
|
|
|
echo "-----"
|
|
|
|
|
2024-03-01 23:18:30 +01:00
|
|
|
read -p "Enable Printer Support: [ false ] " printers
|
|
|
|
user_input_lower=$(echo "$printers" | tr '[:upper:]' '[:lower:]')
|
|
|
|
case $user_input_lower in
|
|
|
|
y|yes|true|t|enable)
|
|
|
|
printers="true"
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
printers="false"
|
|
|
|
;;
|
|
|
|
esac
|
2024-03-01 05:38:55 +01:00
|
|
|
sed -i "/^\s*printer[[:space:]]*=[[:space:]]*\"/s/\"\(.*\)\"/\"$printers\"/" ./options.nix
|
|
|
|
|
|
|
|
echo "-----"
|
|
|
|
|
2024-03-01 23:18:30 +01:00
|
|
|
read -p "Enable Flatpak Support: [ false ] " flatpaks
|
|
|
|
user_input_lower=$(echo "$printers" | tr '[:upper:]' '[:lower:]')
|
|
|
|
case $user_input_lower in
|
|
|
|
y|yes|true|t|enable)
|
|
|
|
printers="true"
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
printers="false"
|
|
|
|
;;
|
|
|
|
esac
|
2024-03-01 05:38:55 +01:00
|
|
|
sed -i "/^\s*flatpak[[:space:]]*=[[:space:]]*\"/s/\"\(.*\)\"/\"$flatpaks\"/" ./options.nix
|
|
|
|
|
|
|
|
echo "-----"
|
|
|
|
|
2024-02-18 06:06:56 +01:00
|
|
|
echo "Valid options include amd, intel, and vm"
|
2024-03-01 23:18:30 +01:00
|
|
|
read -p "Enter Your CPU Type: [ intel ] " cpuType
|
|
|
|
user_input_lower=$(echo "$cpuType" | tr '[:upper:]' '[:lower:]')
|
|
|
|
case $user_input_lower in
|
|
|
|
amd)
|
|
|
|
cpuType="amd"
|
|
|
|
;;
|
|
|
|
intel)
|
|
|
|
cpuType="intel"
|
|
|
|
;;
|
|
|
|
vm)
|
|
|
|
cpuType="vm"
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "Option Entered Not Available, Falling Back To [ intel ] Option."
|
|
|
|
sleep 1
|
|
|
|
cpuType="intel"
|
|
|
|
;;
|
|
|
|
esac
|
2024-02-18 06:06:56 +01:00
|
|
|
sed -i "/^\s*cpuType[[:space:]]*=[[:space:]]*\"/s/\"\(.*\)\"/\"$cpuType\"/" ./options.nix
|
|
|
|
|
|
|
|
echo "-----"
|
|
|
|
|
|
|
|
echo "Valid options include amd, intel, nvidia, vm, intel-nvidia"
|
|
|
|
read -p "Enter Your GPU Type : " gpuType
|
2024-03-01 23:18:30 +01:00
|
|
|
user_input_lower=$(echo "$gpuType" | tr '[:upper:]' '[:lower:]')
|
|
|
|
case $user_input_lower in
|
|
|
|
amd)
|
|
|
|
gpuType="amd"
|
|
|
|
;;
|
|
|
|
intel)
|
|
|
|
gpuType="intel"
|
|
|
|
;;
|
|
|
|
vm)
|
|
|
|
gpuType="vm"
|
|
|
|
;;
|
|
|
|
intel-nvidia)
|
|
|
|
gpuType="intel-nvidia"
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "Option Entered Not Available, Falling Back To [ intel ] Option."
|
|
|
|
sleep 1
|
|
|
|
gpuType="intel"
|
|
|
|
;;
|
|
|
|
esac
|
2024-02-18 06:06:56 +01:00
|
|
|
sed -i "/^\s*gpuType[[:space:]]*=[[:space:]]*\"/s/\"\(.*\)\"/\"$gpuType\"/" ./options.nix
|
|
|
|
|
2024-02-19 10:53:07 +01:00
|
|
|
echo "Generating The Hardware Configuration"
|
2024-02-22 21:32:56 +01:00
|
|
|
sudo nixos-generate-config --show-hardware-config > hardware.nix
|
2024-02-18 06:06:56 +01:00
|
|
|
|
2024-02-19 10:53:07 +01:00
|
|
|
echo "-----"
|
|
|
|
|
|
|
|
echo "Now Going To Build ZaneyOS, 🤞"
|
2024-02-18 06:06:56 +01:00
|
|
|
NIX_CONFIG="experimental-features = nix-command flakes"
|
|
|
|
sudo nixos-rebuild switch --flake .#$hostName
|
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
|