Convert sway from hostname-allowlist to bootstrap prompt
Replaces the implicit hostname-based enable (miche/byte/kaiser got
sway automatically) with an explicit promptBool asked at first init.
New flow:
1. `chezmoi init` asks: "sway_setup? [y/N]"
2. User says y or N (default N)
3. Answer is captured in data.sway_setup
4. run_once_40-install-sway.sh.tmpl gates on .sway_setup
5. Per-box override via marker files (preserved):
- ~/.config/chezmoi/features/sway → force ON
- ~/.config/chezmoi/features/no-sway → force OFF
Migration for existing boxes:
- Miche/byte/kaiser already have ~/.config/chezmoi/features/sway
marker (from previous hostname-allowlist install) → sway_setup=true
- Rye/crouton have no marker → sway_setup=false (default)
- Both groups pick up the new template on next chezmoi apply
This commit is contained in:
parent
5e2a3378cc
commit
a9ba9af8db
2 changed files with 14 additions and 27 deletions
|
|
@ -62,29 +62,16 @@ data:
|
||||||
os_family: {{ $osFamily | quote }}
|
os_family: {{ $osFamily | quote }}
|
||||||
os_id: {{ .chezmoi.osRelease.id | quote }}
|
os_id: {{ .chezmoi.osRelease.id | quote }}
|
||||||
|
|
||||||
# Sway/Wayland desktop stack — enabled per host. Pis don't need it
|
# Sway/Wayland desktop stack — opt-in at bootstrap time. When you
|
||||||
# (headless); x86_64 desktops do. Override at runtime by creating
|
# run `chezmoi init` for the first time, you'll be asked:
|
||||||
# `~/.config/chezmoi/features/sway` (force ON) or
|
# "Install the sway + wofi + foot Wayland desktop stack? [y/N]"
|
||||||
# `~/.config/chezmoi/features/no-sway` (force OFF).
|
# Answering `y` installs the packages and writes the configs.
|
||||||
|
# Answering `N` (or pressing enter for default) skips both.
|
||||||
#
|
#
|
||||||
# To toggle for a new box: `touch ~/.config/chezmoi/features/sway`
|
# To flip later: `touch ~/.config/chezmoi/features/sway` to enable,
|
||||||
# then `chezmoi apply`.
|
# or `touch ~/.config/chezmoi/features/no-sway` to disable, then
|
||||||
{{- $swayOverrideOn := stat (joinPath .chezmoi.homeDir ".config/chezmoi/features/sway") }}
|
# `chezmoi apply`. The marker files override the bootstrap answer.
|
||||||
{{- $swayOverrideOff := stat (joinPath .chezmoi.homeDir ".config/chezmoi/features/no-sway") }}
|
{{- $swayMarker := not (not (stat (joinPath .chezmoi.homeDir ".config/chezmoi/features/sway"))) }}
|
||||||
{{- if $swayOverrideOn }}
|
{{- $noSwayMarker := not (not (stat (joinPath .chezmoi.homeDir ".config/chezmoi/features/no-sway"))) }}
|
||||||
sway: true
|
{{- $swayPrompt := promptBool "sway_setup" false }}
|
||||||
{{- else if $swayOverrideOff }}
|
sway_setup: {{ or $swayMarker (and $swayPrompt (not $noSwayMarker)) }}
|
||||||
sway: false
|
|
||||||
{{- else }}
|
|
||||||
{{- /* Hostname allowlist for the desktop stack. Match if hostname
|
|
||||||
equals or starts with any of the listed prefixes (e.g. "byte"
|
|
||||||
matches both "byte" and "byte-arch"). */}}
|
|
||||||
{{- $swayHosts := list "miche" "byte" "kaiser" }}
|
|
||||||
{{- $swayMatch := false }}
|
|
||||||
{{- range $swayHosts }}
|
|
||||||
{{- if or (eq . $.chezmoi.hostname) (hasPrefix (printf "%s-" .) $.chezmoi.hostname) (hasPrefix (printf "%s." .) $.chezmoi.hostname) }}
|
|
||||||
{{- $swayMatch = true }}
|
|
||||||
{{- end }}
|
|
||||||
{{- end }}
|
|
||||||
sway: {{ $swayMatch }}
|
|
||||||
{{- end }}
|
|
||||||
|
|
@ -16,8 +16,8 @@ set -euo pipefail
|
||||||
log() { printf '\033[1;34m[sway]\033[0m %s\n' "$*"; }
|
log() { printf '\033[1;34m[sway]\033[0m %s\n' "$*"; }
|
||||||
|
|
||||||
# --- 0. Gate on the .sway flag ---
|
# --- 0. Gate on the .sway flag ---
|
||||||
{{ if not .sway -}}
|
{{ if not .sway_setup -}}
|
||||||
log "sway not enabled for this host (.sway=false). Skipping."
|
log "sway_setup not enabled for this host (.sway_setup=false). Skipping."
|
||||||
log "To enable: touch ~/.config/chezmoi/features/sway && chezmoi apply"
|
log "To enable: touch ~/.config/chezmoi/features/sway && chezmoi apply"
|
||||||
exit 0
|
exit 0
|
||||||
{{ end -}}
|
{{ end -}}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue