2024-02-18 06:06:56 +01:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2024-05-19 02:24:55 +02:00
|
|
|
if [ -n "$(grep -i nixos < /etc/os-release)" ]; then
|
|
|
|
echo "Verified this is NixOS."
|
|
|
|
echo "-----"
|
2024-02-18 06:06:56 +01:00
|
|
|
else
|
2024-05-19 02:24:55 +02:00
|
|
|
echo "This is not NixOS or the distribution information is not available."
|
|
|
|
exit
|
2024-02-18 06:06:56 +01:00
|
|
|
fi
|
|
|
|
|
2024-02-19 10:47:42 +01:00
|
|
|
if command -v git &> /dev/null; then
|
2024-05-19 02:24:55 +02:00
|
|
|
echo "Git is installed, continuing with installation."
|
|
|
|
echo "-----"
|
2024-02-19 10:47:42 +01:00
|
|
|
else
|
2024-05-19 02:24:55 +02:00
|
|
|
echo "Git is not installed. Please install Git and try again."
|
|
|
|
echo "Example: nix-shell -p git"
|
|
|
|
exit
|
2024-02-19 10:47:42 +01:00
|
|
|
fi
|
2024-02-18 06:06:56 +01:00
|
|
|
|
2024-05-19 02:24:55 +02:00
|
|
|
echo "Default options are in brackets []"
|
|
|
|
echo "Just press enter to select the default"
|
|
|
|
sleep 2
|
|
|
|
|
2024-02-18 06:06:56 +01:00
|
|
|
echo "-----"
|
|
|
|
|
2024-03-01 05:38:55 +01:00
|
|
|
echo "Ensure In Home Directory"
|
2024-05-19 02:24:55 +02:00
|
|
|
cd || exit
|
2024-03-01 05:38:55 +01:00
|
|
|
|
|
|
|
echo "-----"
|
|
|
|
|
2024-05-19 02:24:55 +02:00
|
|
|
read -rp "Enter Your New Hostname: [ default ] " hostName
|
2024-04-04 03:16:41 +02:00
|
|
|
if [ -z "$hostName" ]; then
|
2024-05-19 02:24:55 +02:00
|
|
|
hostName="default"
|
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."
|
2024-05-19 02:24:55 +02:00
|
|
|
mv "$HOME"/zaneyos .config/zaneyos-backups/"$backupname"
|
2024-04-04 02:24:49 +02:00
|
|
|
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
|
2024-05-19 02:24:55 +02:00
|
|
|
mv "$HOME"/zaneyos .config/zaneyos-backups/"$backupname"
|
2024-04-04 02:24:49 +02:00
|
|
|
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
|
2024-05-19 02:24:55 +02:00
|
|
|
cd zaneyos || exit
|
|
|
|
mkdir hosts/"$hostName"
|
|
|
|
cp hosts/default/*.nix hosts/"$hostName"
|
2024-05-19 20:13:37 +02:00
|
|
|
git config --global user.name "installer"
|
|
|
|
git config --global user.email "installer@gmail.com"
|
|
|
|
git add .
|
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
|
|
|
|
2024-07-24 15:32:51 +02:00
|
|
|
|
|
|
|
read -rp "Enter your keyboard layout: [ us ] " keyboardLayout
|
|
|
|
if [ -z "$keyboardLayout" ]; then
|
|
|
|
keyboardLayout="us"
|
|
|
|
fi
|
|
|
|
|
|
|
|
sed -i "/^\s*keyboardLayout[[:space:]]*=[[:space:]]*\"/s/\"\(.*\)\"/\"$keyboardLayout\"/" ./hosts/$hostName/variables.nix
|
|
|
|
|
2024-04-04 03:26:15 +02:00
|
|
|
echo "-----"
|
|
|
|
|
2024-05-19 20:20:23 +02:00
|
|
|
installusername=$(echo $USER)
|
2024-05-19 02:24:55 +02:00
|
|
|
sed -i "/^\s*username[[:space:]]*=[[:space:]]*\"/s/\"\(.*\)\"/\"$installusername\"/" ./flake.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-06-01 05:42:02 +02:00
|
|
|
echo "Setting Required Nix Settings Then Going To Install"
|
2024-04-18 23:00:04 +02:00
|
|
|
NIX_CONFIG="experimental-features = nix-command flakes"
|
2024-03-02 22:09:30 +01:00
|
|
|
|
2024-03-02 22:25:28 +01:00
|
|
|
echo "-----"
|
|
|
|
|
2024-06-01 05:42:02 +02:00
|
|
|
sudo nixos-rebuild switch --flake ~/zaneyos/#${hostName}
|