1
0
Fork 0

Add Gentoo support with GURU overlay requirement

Tadbit (tadbit-gentoo, x86_64, gcc 15.2.1, TKG kernel) joins the
homelab as the 7th machine — the first gentoo box. Adds Gentoo
support to the bootstrap alongside arch and debian.

New scripts:
- run_once_10-add-gentoo-overlays.sh.tmpl: enables GURU overlay
  via 'eselect repository enable guru' + 'emaint sync -r guru'.
  Idempotent — skips if GURU is already at /var/db/repos/guru.
  GURU is required because eza, lazygit, topgrade, and most modern
  CLI tools only live in GURU (not main).
- run_once_20-install-user-packages-gentoo.sh.tmpl: emerge-based
  user package set. Writes USE flags to package.use/ BEFORE
  emerging so foot/wofi/waybar get the right features. Detects
  missing packages via 'command -v <basename>'. Falls back to
  the official curl installer for bun (no gentoo package).
- run_once_40-install-sway-gentoo.sh.tmpl: sway stack via emerge
  with USE flags for X+wayland+tray+upower+wireplumber.

Updated scripts:
- .chezmoi.yaml.tmpl: os_family detection now also matches 'gentoo'.
  Critical fix: Gentoo's /etc/os-release uses single-quoted values
  ('gentoo' not 'gentoo' or "gentoo"), and chezmoi's parser doesn't
  strip them. Without trimAll "'", .chezmoi.osRelease.id returns
  the literal string 'gentoo' with quotes, and the eq test fails.
  Symptom: os_family silently becomes 'unknown'.
- run_once_00-install-bootstrap-tools.sh.tmpl: added gentoo branch
  that uses emerge --sync + emerge (skipping if tree is < 1 day old).
- run_onchange_30-ensure-cargo.sh.tmpl: added gentoo branch for
  bat (already installed by emerge, just verify), topgrade (GURU),
  cargo-update (dev-util/cargo-update in main).

README: documented Gentoo-specific quirks (USE flags, GURU,
single-quote parsing, no binary packages).
This commit is contained in:
Rain 2026-06-23 15:55:28 -04:00
parent 1b596bd894
commit 36e9d3e0ce
7 changed files with 439 additions and 12 deletions

View file

@ -0,0 +1,90 @@
#!/usr/bin/env bash
# =============================================================================
# run_once_40-install-sway-gentoo.sh.tmpl (gentoo-only)
# Install the sway + wofi + foot + supporting tooling desktop stack on
# gentoo. Equivalent to run_once_40-install-sway.sh.tmpl's arch/debian
# branches.
#
# Gated on .sway_setup. When false (Pis, headless boxes), this script
# exits 0 without doing anything.
# =============================================================================
set -euo pipefail
log() { printf '\033[1;34m[sway]\033[0m %s\n' "$*"; }
# --- 0. Gate on .sway_setup ---
{{ if not .sway_setup -}}
log "sway_setup not enabled for this host (.sway_setup=false). Skipping."
log "To enable: touch ~/.config/chezmoi/features/sway && chezmoi apply"
exit 0
{{ end -}}
# Gentoo package set for sway + companions. All live in the main tree
# except some compositor deps that may need ~amd64.
SWAY_PKGS=(
gui-wm/sway
gui-apps/wofi
gui-apps/foot
gui-apps/swaybg
gui-apps/swaylock
gui-apps/swayidle
media-gfx/grim
media-gfx/slurp
gui-apps/waybar
gui-apps/wl-clipboard
x11-terms/foot-terminfo # for $TERM=foot support
)
log "checking sway stack: ${SWAY_PKGS[*]}"
# On gentoo, USE flags matter. Set the ones we need BEFORE emerging.
USE_DIR="/etc/portage/package.use/sway-bootstrap"
sudo mkdir -p "$(dirname "$USE_DIR")"
# sway itself doesn't need flags, but foot needs `+X +wayland`, waybar
# needs `+X +wayland +network +tray +upower +wireplumber`. Lay them out.
# Note: most gentoo ebuilds for these packages have sensible defaults,
# but be explicit for reproducibility.
sudo tee "$USE_DIR" >/dev/null <<'USE_FLAGS'
gui-wm/sway X wayland
gui-apps/foot X wayland
gui-apps/wofi X wayland
gui-apps/waybar X wayland tray upower wireplumber
USE_FLAGS
# Map package names to actual binaries (some packages ship under a
# different name, e.g. wl-clipboard provides wl-copy/wl-paste).
# On gentoo the package name is `gui-apps/wl-clipboard` but the
# binary is `wl-copy`. Strip the category prefix and look up the map.
declare -A PKG_BIN=(
[gui-apps/wl-clipboard]="wl-copy"
[x11-terms/foot-terminfo]="foot"
)
MISSING_PKGS=()
for p in "${SWAY_PKGS[@]}"; do
bin="${PKG_BIN[$p]:-$(basename "$p")}"
if ! command -v "$bin" >/dev/null 2>&1; then
MISSING_PKGS+=("$p")
fi
done
if (( ${#MISSING_PKGS[@]} > 0 )); then
log "missing: ${MISSING_PKGS[*]}"
log "emerge sway stack (gentoo compiles from source; this may take a while)"
sudo emerge --ask=n --nospinner --quiet-build --keep-going \
--with-bdeps=y --autounmask-license=y \
"${MISSING_PKGS[@]}"
else
log "all sway packages already installed; skipping emerge"
fi
log "sway stack installed"
sway --version 2>&1 | head -1
foot --version 2>&1 | head -1
wofi --version 2>&1 | head -1
# Mark the box so subsequent chezmoi applies know sway is enabled
mkdir -p ~/.config/chezmoi/features
touch ~/.config/chezmoi/features/sway
log "marked box: ~/.config/chezmoi/features/sway"
log "sway stack install complete"