#!/bin/sh # Install packages declared in .chezmoidata/packages.yaml. # packages.yaml hash: {{ include ".chezmoidata/packages.yaml" | sha256sum }} set -eu {{ if eq .chezmoi.os "linux" -}} if [ "$(id -u)" -eq 0 ]; then PACMAN="pacman"; else PACMAN="sudo pacman"; fi # Install only what no installed package already provides (`pacman -T`), so a # machine with mise-bin or yazi-git is not asked to replace them with mise/yazi. install_missing() { missing=$(pacman -T "$@" || true) # shellcheck disable=SC2086 # word splitting intended [ -z "$missing" ] || $PACMAN -S --needed --noconfirm $missing } install_missing {{ range .packages.arch.pacman }}{{ . }} {{ end }} {{ if or (eq .role "desktop") (eq .role "laptop") -}} install_missing {{ range .packages.arch.desktop.pacman }}{{ . }} {{ end }} # [omarchy] repo packages — only where pacman.conf has that repo if pacman-conf -l | grep -qx omarchy; then install_missing {{ range .packages.arch.desktop.omarchy }}{{ . }} {{ end }} fi aur_pkgs="{{ range .packages.arch.desktop.aur }}{{ . }} {{ end }}{{ range .packages.arch.aur }}{{ . }} {{ end }}" {{ else -}} aur_pkgs="{{ range .packages.arch.aur }}{{ . }} {{ end }}" {{ end -}} if [ -n "$(echo "$aur_pkgs" | tr -d ' ')" ]; then if command -v yay >/dev/null 2>&1; then AUR="yay" elif command -v paru >/dev/null 2>&1; then AUR="paru" else AUR=""; fi if [ -n "$AUR" ]; then # shellcheck disable=SC2086 $AUR -S --needed --noconfirm $aur_pkgs else echo "warning: yay/paru not found — skipping AUR packages: $aur_pkgs" >&2 fi fi {{ else if eq .chezmoi.os "darwin" -}} if ! command -v brew >/dev/null 2>&1; then echo "error: homebrew not installed — https://brew.sh" >&2 exit 1 fi brew install \ {{ range .packages.darwin.brew }} {{ . }} \ {{ end }} && true brew install --cask \ {{ range .packages.darwin.cask }} {{ . }} \ {{ end }} && true {{ end -}}