diff --git a/CHANGELOG.md b/CHANGELOG.md index f6e6da4..92ed03b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,8 +2,9 @@ ## ZaneyOS v2.3.3 -- Post GA Release Notes -** Updated: June 27th, 2025 ** +** Updated: June 29th, 2025 ** +- Improved `install-zaneyos.sh` script Detects GPU and better presentation - Added `gemini.nix` Creates an `npm` script to install `gemini-cli` - Added `evil-helix` with language support as option - Added `vscode.nix` with plugins for NIX, BASH, JSON, and VIM keybinds diff --git a/hosts/default/variables.nix b/hosts/default/variables.nix index d0a0cc8..d355512 100644 --- a/hosts/default/variables.nix +++ b/hosts/default/variables.nix @@ -17,9 +17,6 @@ vscodeEnable = false; helixEnable = false; - # P10K or starship prompt (not enabled yet) - userPrompt = "starship"; - # Hyprland Settings # ex: extraMonitorSettings = "monitor = Virtual-1,1920x1080@60,auto,1"; # ex: extraMonitorSettings = "monitor = HDMI-A-1,1920x1080@60,auto,1"; diff --git a/install-zaneyos.sh b/install-zaneyos.sh old mode 100644 new mode 100755 index 20d53dd..0bc96d2 --- a/install-zaneyos.sh +++ b/install-zaneyos.sh @@ -1,119 +1,229 @@ #!/usr/bin/env bash +###################################### +# Install script for zaneyos +# Author: Don Williams +# Date: June 27, 2005 +####################################### + +# Define colors +RED='\033[0;31m' +GREEN='\033[0;32m' +NC='\033[0m' # No Color + +# Define log file +LOG_DIR="$(dirname "$0")" +LOG_FILE="${LOG_DIR}/install_$(date +"%Y-%m-%d_%H-%M-%S").log" + +mkdir -p "$LOG_DIR" +exec > >(tee -a "$LOG_FILE") 2>&1 + +# Function to print a section header +print_header() { + echo -e "${GREEN}╔═══════════════════════════════════════════════════════════════════════╗${NC}" + echo -e "${GREEN}║ ${1} ${NC}" + echo -e "${GREEN}╚═══════════════════════════════════════════════════════════════════════╝${NC}" +} + +# Function to print an error message +print_error() { + echo -e "${RED}Error: ${1}${NC}" +} + +# Function to print a success banner +print_success_banner() { + echo -e "${GREEN}╔═══════════════════════════════════════════════════════════════════════╗${NC}" + echo -e "${GREEN}║ ZaneyOS Installation Successful! ║${NC}" + echo -e "${GREEN}║ ║${NC}" + echo -e "${GREEN}║ Please reboot your system for changes to take full effect. ║${NC}" + echo -e "${GREEN}║ ║${NC}" + echo -e "${GREEN}╚═══════════════════════════════════════════════════════════════════════╝${NC}" +} + +# Function to print a failure banner +print_failure_banner() { + echo -e "${RED}╔═══════════════════════════════════════════════════════════════════════╗${NC}" + echo -e "${RED}║ ZaneyOS Installation Failed! ║${NC}" + echo -e "${RED}║ ║${NC}" + echo -e "${RED}║ Please review the log file for details: ║${NC}" + echo -e "${RED}║ ${LOG_FILE} ║${NC}" + echo -e "${RED}║ ║${NC}" + echo -e "${RED}╚═══════════════════════════════════════════════════════════════════════╝${NC}" +} + +print_header "Verifying System Requirements" + +# Check for git +if ! command -v git &> /dev/null; then + print_error "Git is not installed." + echo -e "Please install git and pciutils are installed, then re-run the install script." + echo -e "Example: nix-shell -p git pciutils" + exit 1 +fi + +# Check for lspci (pciutils) +if ! command -v lspci &> /dev/null; then + print_error "pciutils is not installed." + echo -e "Please install git and pciutils, then re-run the install script." + echo -e "Example: nix-shell -p git pciutils" + exit 1 +fi + if [ -n "$(grep -i nixos < /etc/os-release)" ]; then - echo "Verified this is NixOS." - echo "-----" + echo -e "${GREEN}Verified this is NixOS.${NC}" else - echo "This is not NixOS or the distribution information is not available." - exit + print_error "This is not NixOS or the distribution information is not available." + exit 1 fi -if command -v git &> /dev/null; then - echo "Git is installed, continuing with installation." - echo "-----" -else - echo "Git is not installed. Please install Git and try again." - echo "Example: nix-shell -p git" - exit -fi +print_header "Initial Setup" -echo "Default options are in brackets []" -echo "Just press enter to select the default" +echo -e "Default options are in brackets []" +echo -e "Just press enter to select the default" sleep 2 -echo "-----" - -echo "Ensure In Home Directory" -cd || exit - -echo "-----" +print_header "Ensure In Home Directory" +cd "$HOME" || exit 1 +echo -e "${GREEN}Current directory: $(pwd)${NC}" +print_header "Hostname Configuration" read -rp "Enter Your New Hostname: [ default ] " hostName if [ -z "$hostName" ]; then hostName="default" fi -echo "-----" +print_header "GPU Profile Detection" -read -rp "Enter Your Hardware Profile (GPU) -Options: -[ amd ] -nvidia -nvidia-laptop -intel -vm -Please type out your choice: " profile -if [ -z "$profile" ]; then - profile="amd" +# Attempt automatic detection +DETECTED_PROFILE="" + +has_nvidia=false +has_intel=false +has_amd=false +has_vm=false + +if lspci | grep -qi 'vga\|3d'; then + while read -r line; do + if echo "$line" | grep -qi 'nvidia'; then + has_nvidia=true + elif echo "$line" | grep -qi 'amd'; then + has_amd=true + elif echo "$line" | grep -qi 'intel'; then + has_intel=true + elif echo "$line" | grep -qi 'virtio\|vmware'; then + has_vm=true + fi + done < <(lspci | grep -i 'vga\|3d') + + if $has_vm; then + DETECTED_PROFILE="vm" + elif $has_nvidia && $has_intel; then + DETECTED_PROFILE="hybrid" + elif $has_nvidia; then + DETECTED_PROFILE="nvidia" + elif $has_amd; then + DETECTED_PROFILE="amd" + elif $has_intel; then + DETECTED_PROFILE="intel" + fi fi -echo "-----" +# Handle detected profile or fall back to manual input +if [ -n "$DETECTED_PROFILE" ]; then + profile="$DETECTED_PROFILE" + echo -e "${GREEN}Detected GPU profile: $profile${NC}" + read -p "Correct? (Y/N): " -n 1 -r + echo + if [[ ! $REPLY =~ ^[Yy]$ ]]; then + echo -e "${RED}GPU profile not confirmed. Falling back to manual selection.${NC}" + profile="" # Clear profile to force manual input + fi +fi -backupname=$(date "+%Y-%m-%d-%H-%M-%S") +# If profile is still empty (either not detected or not confirmed), prompt manually +if [ -z "$profile" ]; then + echo -e "${RED}Automatic GPU detection failed or no specific profile found.${NC}" + read -rp "Enter Your Hardware Profile (GPU)\nOptions:\n[ amd ]\nnvidia\nnvidia-laptop\nintel\nvm\nPlease type out your choice: " profile + if [ -z "$profile" ]; then + profile="amd" + fi + echo -e "${GREEN}Selected GPU profile: $profile${NC}" +fi + +print_header "Backup Existing ZaneyOS (if any)" + +backupname=$(date +"%Y-%m-%d-%H-%M-%S") if [ -d "zaneyos" ]; then - echo "ZaneyOS exists, backing up to .config/zaneyos-backups folder." + echo -e "${GREEN}zaneyos exists, backing up to .config/zaneyos-backups folder.${NC}" if [ -d ".config/zaneyos-backups" ]; then - echo "Moving current version of ZaneyOS to backups folder." + echo -e "${GREEN}Moving current version of ZaneyOS to backups folder.${NC}" mv "$HOME"/zaneyos .config/zaneyos-backups/"$backupname" sleep 1 else - echo "Creating the backups folder & moving ZaneyOS to it." + echo -e "${GREEN}Creating the backups folder & moving ZaneyOS to it.${NC}" mkdir -p .config/zaneyos-backups mv "$HOME"/zaneyos .config/zaneyos-backups/"$backupname" sleep 1 fi else - echo "Thank you for choosing ZaneyOS." - echo "I hope you find your time here enjoyable!" + echo -e "${GREEN}Thank you for choosing ZaneyOS.${NC}" + echo -e "${GREEN}I hope you find your time here enjoyable!${NC}" fi -echo "-----" +print_header "Cloning ZaneyOS Repository" +git clone https://gitlab.com/zaney/zaneyos.git --depth=1 -b stable-2.3 ~/zaneyos +cd ~/zaneyos || exit 1 -echo "Cloning & Entering ZaneyOS Repository" -git clone https://gitlab.com/zaney/zaneyos.git -b stable-2.3 --single-branch -cd zaneyos || exit -mkdir hosts/"$hostName" +print_header "Configuring Host and Profile" +mkdir -p hosts/"$hostName" cp hosts/default/*.nix hosts/"$hostName" + installusername=$(echo $USER) git config --global user.name "$installusername" git config --global user.email "$installusername@gmail.com" git add . git config --global --unset-all user.name git config --global --unset-all user.email -sed -i "/^\s*host[[:space:]]*=[[:space:]]*\"/s/\"\(.*\)\"/\"$hostName\"/" ./flake.nix -sed -i "/^\s*profile[[:space:]]*=[[:space:]]*\"/s/\"\(.*\)\"/\"$profile\"/" ./flake.nix +sed -i "/^[[:space:]]*host[[:space:]]*=[[:space:]]*\"/s/\"\(.*\)\"/\"$hostName\"/" ./flake.nix +sed -i "/^[[:space:]]*profile[[:space:]]*=[[:space:]]*\"/s/\"\(.*\)\"/\"$profile\"/" ./flake.nix +print_header "Keyboard Layout Configuration" read -rp "Enter your keyboard layout: [ us ] " keyboardLayout if [ -z "$keyboardLayout" ]; then keyboardLayout="us" fi +sed -i "/^[[:space:]]*keyboardLayout[[:space:]]*=[[:space:]]*\"/s/\"\(.*\)\"/\"$keyboardLayout\"/" ./hosts/$hostName/variables.nix -sed -i "/^\s*keyboardLayout[[:space:]]*=[[:space:]]*\"/s/\"\(.*\)\"/\"$keyboardLayout\"/" ./hosts/$hostName/variables.nix - -echo "-----" - +print_header "Console Keymap Configuration" read -rp "Enter your console keymap: [ us ] " consoleKeyMap if [ -z "$consoleKeyMap" ]; then consoleKeyMap="us" fi +sed -i "/^[[:space:]]*consoleKeyMap[[:space:]]*=[[:space:]]*\"/s/\"\(.*\)\"/\"$consoleKeyMap\"/" ./hosts/$hostName/variables.nix -sed -i "/^\s*consoleKeyMap[[:space:]]*=[[:space:]]*\"/s/\"\(.*\)\"/\"$consoleKeyMap\"/" ./hosts/$hostName/variables.nix +print_header "Username Configuration" +sed -i "/^[[:space:]]*username[[:space:]]*=[[:space:]]*\"/s/\"\(.*\)\"/\"$installusername\"/" ./flake.nix -echo "-----" - -sed -i "/^\s*username[[:space:]]*=[[:space:]]*\"/s/\"\(.*\)\"/\"$installusername\"/" ./flake.nix - -echo "-----" - -echo "Generating The Hardware Configuration" +print_header "Generating Hardware Configuration -- Ignore ERROR: cannot access /bin" sudo nixos-generate-config --show-hardware-config > ./hosts/$hostName/hardware.nix -echo "-----" - -echo "Setting Required Nix Settings Then Going To Install" +print_header "Setting Nix Configuration" NIX_CONFIG="experimental-features = nix-command flakes" -echo "-----" +print_header "Initiating NixOS Build" +read -p "Ready to run initial build? (Y/N): " -n 1 -r +echo +if [[ ! $REPLY =~ ^[Yy]$ ]]; then + echo -e "${RED}Build cancelled.${NC}" + exit 1 +fi -sudo nixos-rebuild switch --flake ~/zaneyos/#${profile} +sudo nixos-rebuild boot --flake ~/zaneyos/#${profile} + +# Check the exit status of the last command (nixos-rebuild) +if [ $? -eq 0 ]; then + print_success_banner +else + print_failure_banner +fi diff --git a/modules/home/default.nix b/modules/home/default.nix index a019532..dc40c24 100644 --- a/modules/home/default.nix +++ b/modules/home/default.nix @@ -33,8 +33,8 @@ in { ./rofi ./qt.nix ./scripts - ./starship.nix - ./starship-ddubs-1.nix + #./starship.nix + #./starship-ddubs-1.nix ./stylix.nix ./swappy.nix ./swaync.nix diff --git a/modules/home/install-zaneyos.sh b/modules/home/install-zaneyos.sh new file mode 100755 index 0000000..7f24afc --- /dev/null +++ b/modules/home/install-zaneyos.sh @@ -0,0 +1,229 @@ +#!/usr/bin/env bash + +###################################### +# Install script for zaneyos +# Author: Don Williams +# Date: June 27, 2005 +####################################### + +# Define colors +RED='\033[0;31m' +GREEN='\033[0;32m' +NC='\033[0m' # No Color + +# Define log file +LOG_DIR="$(dirname "$0")" +LOG_FILE="${LOG_DIR}/install_$(date +"%Y-%m-%d_%H-%M-%S").log" + +mkdir -p "$LOG_DIR" +exec > >(tee -a "$LOG_FILE") 2>&1 + +# Function to print a section header +print_header() { + echo -e "${GREEN}╔═══════════════════════════════════════════════════════════════════════╗${NC}" + echo -e "${GREEN}║ ${1} ${NC}" + echo -e "${GREEN}╚═══════════════════════════════════════════════════════════════════════╝${NC}" +} + +# Function to print an error message +print_error() { + echo -e "${RED}Error: ${1}${NC}" +} + +# Function to print a success banner +print_success_banner() { + echo -e "${GREEN}╔═══════════════════════════════════════════════════════════════════════╗${NC}" + echo -e "${GREEN}║ zaneyos Installation Successful! ║${NC}" + echo -e "${GREEN}║ ║${NC}" + echo -e "${GREEN}║ Please reboot your system for changes to take full effect. ║${NC}" + echo -e "${GREEN}║ ║${NC}" + echo -e "${GREEN}╚═══════════════════════════════════════════════════════════════════════╝${NC}" +} + +# Function to print a failure banner +print_failure_banner() { + echo -e "${RED}╔═══════════════════════════════════════════════════════════════════════╗${NC}" + echo -e "${RED}║ zaneyos Installation Failed! ║${NC}" + echo -e "${RED}║ ║${NC}" + echo -e "${RED}║ Please review the log file for details: ║${NC}" + echo -e "${RED}║ ${LOG_FILE} ║${NC}" + echo -e "${RED}║ ║${NC}" + echo -e "${RED}╚═══════════════════════════════════════════════════════════════════════╝${NC}" +} + +print_header "Verifying System Requirements" + +# Check for git +if ! command -v git &> /dev/null; then + print_error "Git is not installed." + echo -e "Please install git and pciutils are installed, then re-run the install script." + echo -e "Example: nix-shell -p git pciutils" + exit 1 +fi + +# Check for lspci (pciutils) +if ! command -v lspci &> /dev/null; then + print_error "pciutils is not installed." + echo -e "Please install git and pciutils, then re-run the install script." + echo -e "Example: nix-shell -p git pciutils" + exit 1 +fi + +if [ -n "$(grep -i nixos < /etc/os-release)" ]; then + echo -e "${GREEN}Verified this is NixOS.${NC}" +else + print_error "This is not NixOS or the distribution information is not available." + exit 1 +fi + +print_header "Initial Setup" + +echo -e "Default options are in brackets []" +echo -e "Just press enter to select the default" +sleep 2 + +print_header "Ensure In Home Directory" +cd "$HOME" || exit 1 +echo -e "${GREEN}Current directory: $(pwd)${NC}" + +print_header "Hostname Configuration" +read -rp "Enter Your New Hostname: [ default ] " hostName +if [ -z "$hostName" ]; then + hostName="default" +fi + +print_header "GPU Profile Detection" + +# Attempt automatic detection +DETECTED_PROFILE="" + +has_nvidia=false +has_intel=false +has_amd=false +has_vm=false + +if lspci | grep -qi 'vga\|3d'; then + while read -r line; do + if echo "$line" | grep -qi 'nvidia'; then + has_nvidia=true + elif echo "$line" | grep -qi 'amd'; then + has_amd=true + elif echo "$line" | grep -qi 'intel'; then + has_intel=true + elif echo "$line" | grep -qi 'virtio\|vmware'; then + has_vm=true + fi + done < <(lspci | grep -i 'vga\|3d') + + if $has_vm; then + DETECTED_PROFILE="vm" + elif $has_nvidia && $has_intel; then + DETECTED_PROFILE="hybrid" + elif $has_nvidia; then + DETECTED_PROFILE="nvidia" + elif $has_amd; then + DETECTED_PROFILE="amd" + elif $has_intel; then + DETECTED_PROFILE="intel" + fi +fi + +# Handle detected profile or fall back to manual input +if [ -n "$DETECTED_PROFILE" ]; then + profile="$DETECTED_PROFILE" + echo -e "${GREEN}Detected GPU profile: $profile${NC}" + read -p "Correct? (Y/N): " -n 1 -r + echo + if [[ ! $REPLY =~ ^[Yy]$ ]]; then + echo -e "${RED}GPU profile not confirmed. Falling back to manual selection.${NC}" + profile="" # Clear profile to force manual input + fi +fi + +# If profile is still empty (either not detected or not confirmed), prompt manually +if [ -z "$profile" ]; then + echo -e "${RED}Automatic GPU detection failed or no specific profile found.${NC}" + read -rp "Enter Your Hardware Profile (GPU)\nOptions:\n[ amd ]\nnvidia\nnvidia-laptop\nintel\nvm\nPlease type out your choice: " profile + if [ -z "$profile" ]; then + profile="amd" + fi + echo -e "${GREEN}Selected GPU profile: $profile${NC}" +fi + +print_header "Backup Existing zaneyos (if any)" + +backupname=$(date +"%Y-%m-%d-%H-%M-%S") +if [ -d "zaneyos" ]; then + echo -e "${GREEN}zaneyos exists, backing up to .config/zaneyos-backups folder.${NC}" + if [ -d ".config/zaneyos-backups" ]; then + echo -e "${GREEN}Moving current version of zaneyos to backups folder.${NC}" + mv "$HOME"/zaneyos .config/zaneyos-backups/"$backupname" + sleep 1 + else + echo -e "${GREEN}Creating the backups folder & moving zaneyos to it.${NC}" + mkdir -p .config/zaneyos-backups + mv "$HOME"/zaneyos .config/zaneyos-backups/"$backupname" + sleep 1 + fi +else + echo -e "${GREEN}Thank you for choosing zaneyos.${NC}" + echo -e "${GREEN}I hope you find your time here enjoyable!${NC}" +fi + +print_header "Cloning zaneyos Repository" +git clone https://gitlab.com/dwilliam62/zaneyos.git --depth=1 ~/zaneyos +cd ~/zaneyos || exit 1 + +print_header "Configuring Host and Profile" +mkdir -p hosts/"$hostName" +cp hosts/default/*.nix hosts/"$hostName" + +installusername=$(echo $USER) +git config --global user.name "$installusername" +git config --global user.email "$installusername@gmail.com" +git add . +git config --global --unset-all user.name +git config --global --unset-all user.email + +sed -i "/^[[:space:]]*host[[:space:]]*=[[:space:]]*\"/s/\"\(.*\)\"/\"$hostName\"/" ./flake.nix +sed -i "/^[[:space:]]*profile[[:space:]]*=[[:space:]]*\"/s/\"\(.*\)\"/\"$profile\"/" ./flake.nix + +print_header "Keyboard Layout Configuration" +read -rp "Enter your keyboard layout: [ us ] " keyboardLayout +if [ -z "$keyboardLayout" ]; then + keyboardLayout="us" +fi +sed -i "/^[[:space:]]*keyboardLayout[[:space:]]*=[[:space:]]*\"/s/\"\(.*\)\"/\"$keyboardLayout\"/" ./hosts/$hostName/variables.nix + +print_header "Console Keymap Configuration" +read -rp "Enter your console keymap: [ us ] " consoleKeyMap +if [ -z "$consoleKeyMap" ]; then + consoleKeyMap="us" +fi +sed -i "/^[[:space:]]*consoleKeyMap[[:space:]]*=[[:space:]]*\"/s/\"\(.*\)\"/\"$consoleKeyMap\"/" ./hosts/$hostName/variables.nix + +print_header "Username Configuration" +sed -i "/^[[:space:]]*username[[:space:]]*=[[:space:]]*\"/s/\"\(.*\)\"/\"$installusername\"/" ./flake.nix + +print_header "Generating Hardware Configuration -- Ignore ERROR: cannot access /bin" +sudo nixos-generate-config --show-hardware-config > ./hosts/$hostName/hardware.nix + +print_header "Setting Nix Configuration" +NIX_CONFIG="experimental-features = nix-command flakes" + +print_header "Initiating NixOS Build" +read -p "Ready to run initial build? (Y/N): " -n 1 -r +echo +if [[ ! $REPLY =~ ^[Yy]$ ]]; then + echo -e "${RED}Build cancelled.${NC}" + exit 1 +fi + +sudo nixos-rebuild boot --flake ~/zaneyos/#${profile} + +# Check the exit status of the last command (nixos-rebuild) +if [ $? -eq 0 ]; then + print_success_banner +else + print_failure_banner +fi