1
0
Fork 0
gnu-plus-dotfiles/run_once_40-install-sway-gentoo.sh.tmpl
rain 598ad9dfae Gentoo: add --autounmask=y to handle ~amd64 keyword unmask
lazygit and most GURU packages are ~amd64 only. Without --autounmask=y,
emerge fails with: =dev-vcs/lazygit-0.62.2 ~amd64 required.

Applied to run_once_20-install-user-packages-gentoo.sh.tmpl and
run_once_40-install-sway-gentoo.sh.tmpl.
2026-06-23 17:01:44 -04:00

90 lines
No EOL
3 KiB
Bash

#!/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=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"