From b78e23aa169a06fc1eba3b41d9d2f22604fc6011 Mon Sep 17 00:00:00 2001 From: rain Date: Thu, 25 Jun 2026 18:58:27 -0400 Subject: [PATCH] gentoo install scripts: guard with os_family like overlays MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Both run_once_20-install-user-packages-gentoo.sh.tmpl and run_once_40-install-sway-gentoo.sh.tmpl were missing the os_family template guard (the overlays script got it in the previous fix but these two slipped through). On non-gentoo boxes — arch, debian — chezmoi apply would run them and they'd try to 'emerge', failing with 'sudo: emerge: command not found' and exit status 1, which breaks topgrade. Wrap each body in '$0{ if eq .os_family "gentoo" }' / '$0{ else }', mirroring the chaotic-aur script's pattern and the overlays fix from the previous commit. On non-gentoo boxes the rendered script reduces to a single 'skipping' log line and exits 0; on gentoo boxes the full body (including the existing .sway_setup gate on the sway script) is preserved. Verified by rendering both scripts with a gentoo-config override: arch (live) -> 'skipping gentoo user-packages' / 'skipping sway' gentoo -> full body (293 / 87 lines) Both pass bash -n and actually exit 0 when run on this arch box. --- run_once_20-install-user-packages-gentoo.sh.tmpl | 7 ++++++- run_once_40-install-sway-gentoo.sh.tmpl | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/run_once_20-install-user-packages-gentoo.sh.tmpl b/run_once_20-install-user-packages-gentoo.sh.tmpl index 21f8f71..083ce22 100644 --- a/run_once_20-install-user-packages-gentoo.sh.tmpl +++ b/run_once_20-install-user-packages-gentoo.sh.tmpl @@ -24,6 +24,7 @@ die() { printf '\033[1;31m[packages ERROR]\033[0m %s\n' "$*" >&2; exit 1; } USER_HOME="${HOME:-$(eval echo "~$(whoami)")}" ZSH_CUSTOM="${ZSH_CUSTOM:-$USER_HOME/.oh-my-zsh/custom}" +{{ if eq .os_family "gentoo" -}} # ----------------------------- GENTOO --------------------------------------- # On gentoo, `emerge` is the only PM (plus the GURU overlay for some # packages). Many of the user packages live in GURU, so we run emerge with @@ -290,4 +291,8 @@ fi log "all user packages installed" zsh --version nvim --version | head -1 -tmux -V \ No newline at end of file +tmux -V +{{ else -}} +# Not a gentoo box — nothing to do (guarded by os_family above). +log "skipping gentoo user-packages (os_family={{ .os_family }}, not gentoo)" +{{ end -}} \ No newline at end of file diff --git a/run_once_40-install-sway-gentoo.sh.tmpl b/run_once_40-install-sway-gentoo.sh.tmpl index 436dcd1..e965d65 100644 --- a/run_once_40-install-sway-gentoo.sh.tmpl +++ b/run_once_40-install-sway-gentoo.sh.tmpl @@ -12,6 +12,7 @@ set -euo pipefail log() { printf '\033[1;34m[sway]\033[0m %s\n' "$*"; } +{{ if eq .os_family "gentoo" -}} # --- 0. Gate on .sway_setup --- {{ if not .sway_setup -}} log "sway_setup not enabled for this host (.sway_setup=false). Skipping." @@ -87,4 +88,8 @@ mkdir -p ~/.config/chezmoi/features touch ~/.config/chezmoi/features/sway log "marked box: ~/.config/chezmoi/features/sway" -log "sway stack install complete" \ No newline at end of file +log "sway stack install complete" +{{ else -}} +# Not a gentoo box — nothing to do (guarded by os_family above). +log "skipping gentoo sway install (os_family={{ .os_family }}, not gentoo)" +{{ end -}} \ No newline at end of file