1
0
Fork 0
gnu-plus-dotfiles/run_once_10-add-chaotic-aur.sh.tmpl
rain 01eda7cd7f Drop id -u root check from run_once scripts
chezmoi runs run_once_* scripts as the invoking user (uid != 0).
The earlier check [[ $(id -u) -ne 0 ]] && die ... killed the script
immediately when invoked via 'chezmoi apply' or 'chezmoi init --apply'
from a normal user session.

The scripts use sudo internally for package operations (pacman/apt),
so elevation happens correctly. The id -u check was wrong: it belongs
in a script that's *meant* to be invoked as root directly, not in a
chezmoi-managed script.
2026-06-21 19:41:50 -04:00

54 lines
No EOL
1.8 KiB
Bash
Executable file

#!/usr/bin/env bash
# =============================================================================
# run_once_10-add-chaotic-aur.sh.tmpl (arch-only)
# Add Chaotic-AUR repo + keyring to pacman, then install paru from there.
# Reference: https://aur.chaotic.cx/docs
#
# Steps from chaotic docs:
# 1. Get and sign the key
# 2. Install chaotic-keyring + chaotic-mirrorlist
# 3. Append repo to /etc/pacman.conf
# =============================================================================
set -euo pipefail
log() { printf '\033[1;34m[chaotic]\033[0m %s\n' "$*"; }
die() { printf '\033[1;31m[chaotic ERROR]\033[0m %s\n' "$*" >&2; exit 1; }
# This script runs as the invoking user; sudo handles elevation for pacman
# and pacman-key operations below.
if command -v paru >/dev/null 2>&1; then
log "paru already installed — skipping chaotic setup"
exit 0
fi
# Chaotic's official bootstrap. Run as root because pacman-key needs it.
log "fetching chaotic key (3056513887B78AEB)"
pacman-key --recv-key 3056513887B78AEB
pacman-key --lsign-key 3056513887B78AEB
log "installing chaotic-keyring and chaotic-mirrorlist"
pacman -U --noconfirm \
'https://cdn-mirror.chaotic.cx/chaotic-aur/chaotic-keyring.pkg.tar.zst' \
'https://cdn-mirror.chaotic.cx/chaotic-aur/chaotic-mirrorlist.pkg.tar.zst'
# Append chaotic repo to pacman.conf if not already present
if ! grep -q "^\[chaotic-aur\]" /etc/pacman.conf; then
log "appending chaotic-aur to /etc/pacman.conf"
cat >> /etc/pacman.conf <<'PACMAN_EOF'
[chaotic-aur]
Include = /etc/pacman.d/chaotic-mirrorlist
PACMAN_EOF
else
log "chaotic-aur already in /etc/pacman.conf"
fi
log "full system sync with chaotic enabled"
pacman -Syu --noconfirm
log "installing paru from chaotic-aur"
pacman -S --needed --noconfirm paru
log "chaotic-aur + paru ready"
paru --version