#!/bin/bash # Install base packages using the appropriate package manager # This script runs once before other chezmoi operations set -e echo "==> Installing base packages..." {{ if eq .pkgManager "pacman" -}} # Arch Linux (rufus) echo "==> Detected Arch Linux, using pacman..." # Update package database sudo pacman -Sy --noconfirm # Core CLI tools sudo pacman -S --noconfirm --needed \ fish \ helix \ neovim \ ripgrep \ fd \ bat \ eza \ fzf \ jq \ tmux \ git \ base-devel \ keychain {{ if .hasGUI -}} # GUI tools (only on machines with GUI) # Check if paru is installed for AUR packages if ! command -v paru &> /dev/null; then echo "==> Installing paru for AUR packages..." cd /tmp git clone https://aur.archlinux.org/paru.git cd paru makepkg -si --noconfirm cd - rm -rf /tmp/paru fi # Install Ghostty from AUR echo "==> Installing Ghostty from AUR..." paru -S --noconfirm --needed ghostty {{ end -}} {{ else if eq .pkgManager "apt" -}} # Debian/Ubuntu (maple server) echo "==> Detected Debian/Ubuntu, using apt..." sudo apt-get update # Core CLI tools sudo apt-get install -y \ fish \ neovim \ ripgrep \ fd-find \ bat \ fzf \ jq \ tmux \ git \ curl \ wget \ build-essential \ keychain # fd is installed as fdfind on Debian, create symlink if [ ! -f ~/.local/bin/fd ] && command -v fdfind &> /dev/null; then mkdir -p ~/.local/bin ln -sf $(which fdfind) ~/.local/bin/fd fi # bat is installed as batcat on Debian, create symlink if [ ! -f ~/.local/bin/bat ] && command -v batcat &> /dev/null; then mkdir -p ~/.local/bin ln -sf $(which batcat) ~/.local/bin/bat fi # Install eza (modern ls replacement) if ! command -v eza &> /dev/null; then echo "==> Installing eza..." sudo mkdir -p /etc/apt/keyrings wget -qO- https://raw.githubusercontent.com/eza-community/eza/main/deb.asc | sudo gpg --dearmor -o /etc/apt/keyrings/gierens.gpg echo "deb [signed-by=/etc/apt/keyrings/gierens.gpg] http://deb.gierens.de stable main" | sudo tee /etc/apt/sources.list.d/gierens.list sudo chmod 644 /etc/apt/keyrings/gierens.gpg /etc/apt/sources.list.d/gierens.list sudo apt-get update sudo apt-get install -y eza fi # Install Helix from GitHub releases (not in apt repos) if ! command -v hx &> /dev/null; then echo "==> Installing Helix from GitHub releases..." HELIX_VERSION=$(curl -s https://api.github.com/repos/helix-editor/helix/releases/latest | jq -r '.tag_name') curl -Lo /tmp/helix.tar.xz "https://github.com/helix-editor/helix/releases/download/${HELIX_VERSION}/helix-${HELIX_VERSION}-x86_64-linux.tar.xz" sudo tar -xf /tmp/helix.tar.xz -C /usr/local/lib/ sudo ln -sf /usr/local/lib/helix-${HELIX_VERSION}-x86_64-linux/hx /usr/local/bin/hx rm /tmp/helix.tar.xz echo "==> Helix installed. Set HELIX_RUNTIME=/usr/local/lib/helix-${HELIX_VERSION}-x86_64-linux/runtime" fi {{ else if eq .pkgManager "brew" -}} # macOS (macbook) echo "==> Detected macOS, using Homebrew..." # Install Homebrew if not present if ! command -v brew &> /dev/null; then echo "==> Installing Homebrew..." /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" eval "$(/opt/homebrew/bin/brew shellenv)" fi # Core CLI tools brew install \ fish \ helix \ neovim \ ripgrep \ fd \ bat \ eza \ fzf \ jq \ tmux \ git \ keychain {{ if .hasGUI -}} # GUI tools (only on machines with GUI) echo "==> Installing Ghostty..." brew install --cask ghostty {{ end -}} {{ end -}} # Change default shell to fish if not already if [ "$SHELL" != "$(which fish)" ]; then echo "==> Setting fish as default shell..." # Add fish to /etc/shells if not present if ! grep -q "$(which fish)" /etc/shells; then echo "$(which fish)" | sudo tee -a /etc/shells fi chsh -s "$(which fish)" fi echo "==> Base packages installed successfully!"