#!/usr/bin/env bash set -euo pipefail ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" source "$ROOT/lib.sh" need_cmd brew #────────────────────────────────────────────────────────────── # STATE: Formulae to install #────────────────────────────────────────────────────────────── FORMULAE=( bash bash-completion@2 curl git neovim trash mise direnv protonpass/tap/pass-cli ripgrep fd git-delta eza stow starship anomalyco/tap/opencode jq gum viu podman podman-compose ffmpeg ramonvermeulen/whosthere/whosthere ) #────────────────────────────────────────────────────────────── # LOGIC: Idempotent convergence (strict mode) #────────────────────────────────────────────────────────────── log "Updating Homebrew" brew update brew upgrade || true log "Syncing formulae (strict mode)" # Get currently installed (only explicitly requested) mapfile -t installed < <(brew list --formula --installed-on-request 2>/dev/null || true) # Install missing for formula in "${FORMULAE[@]}"; do name="${formula##*/}" if ! brew list --formula "$name" &>/dev/null; then log "Installing: $formula" brew install "$formula" else log "Already installed: $name" fi done # Remove extras (strict convergence) for pkg in "${installed[@]}"; do [[ -z "$pkg" ]] && continue keep=false for formula in "${FORMULAE[@]}"; do [[ "${formula##*/}" == "$pkg" ]] && keep=true && break done if [[ "$keep" == "false" ]]; then log "Removing: $pkg (not in state)" brew uninstall "$pkg" fi done brew cleanup log "Formulae synced" # Configure Podman as Docker replacement if command -v podman &>/dev/null; then log "Creating Docker symlink for Podman" sudo ln -sf "$(which podman)" /usr/local/bin/docker log "Docker symlink created" fi