feat(installer): add shell_rc preference to skip copying .*rcs to skel

Adds a dialog (interactive + answerfile) letting the user choose whether
to copy the dotfiles' .zshrc / .bashrc / .vimrc into /etc/skel, or leave
system defaults in place. The choice is persisted as shell_rc in the
answerfile JSON and respected by both the TUI installer and the generator.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
main
Amir Alexander Abdelbaki 2026-06-26 09:05:00 +02:00
parent 357a19cb8c
commit 8b9c5c70b2
2 changed files with 34 additions and 5 deletions

View File

@ -179,6 +179,7 @@ dialog --backtitle "$BACKTITLE" \
AF_COMPONENTS="" AF_COMPONENTS=""
AF_DE="none" AF_DE="none"
AF_APPS="" AF_APPS=""
AF_SHELL_RC="dotfiles"
AF_COLOR_TEXT="" AF_COLOR_TEXT=""
AF_COLOR_BG="" AF_COLOR_BG=""
AF_COLOR_HIGHLIGHT="" AF_COLOR_HIGHLIGHT=""
@ -294,6 +295,14 @@ if [[ "$AF_RUN_TUI" == "true" ]]; then
"qemu" "QEMU/KVM full virt stack + virt-manager GUI" off \ "qemu" "QEMU/KVM full virt stack + virt-manager GUI" off \
3>&1 1>&2 2>&3) || AF_APPS="" 3>&1 1>&2 2>&3) || AF_APPS=""
# ── Shell RC preference ───────────────────────────────────────────────────
AF_SHELL_RC=$(dialog --backtitle "$BACKTITLE" \
--title " Shell Config for New Users " \
--menu "\n Should new users on this machine inherit the dotfiles' rc files?\n (Controls what gets copied to /etc/skel)\n" 13 68 2 \
"dotfiles" "Use the_miro's .zshrc / .bashrc / .vimrc from dotfiles" \
"defaults" "Skip — use system defaults for new users" \
3>&1 1>&2 2>&3) || AF_SHELL_RC="defaults"
# ── Colorway ────────────────────────────────────────────────────────────── # ── Colorway ──────────────────────────────────────────────────────────────
# Read defaults from repo colors.conf # Read defaults from repo colors.conf
declare -A _cdef declare -A _cdef
@ -355,6 +364,7 @@ SUMMARY+=" Encrypt: $AF_ENCRYPT\n"
SUMMARY+=" FIDO2 root: $AF_FIDO2_ROOT / FIDO2 user: $AF_FIDO2_USER\n" SUMMARY+=" FIDO2 root: $AF_FIDO2_ROOT / FIDO2 user: $AF_FIDO2_USER\n"
SUMMARY+=" Run TUI: $AF_RUN_TUI\n" SUMMARY+=" Run TUI: $AF_RUN_TUI\n"
[[ -n "$AF_DE" && "$AF_DE" != "none" ]] && SUMMARY+=" DE: $AF_DE\n" [[ -n "$AF_DE" && "$AF_DE" != "none" ]] && SUMMARY+=" DE: $AF_DE\n"
SUMMARY+=" Shell rc: $AF_SHELL_RC\n"
[[ -n "$AF_COLOR_TEXT" ]] && SUMMARY+=" Colors: custom\n" [[ -n "$AF_COLOR_TEXT" ]] && SUMMARY+=" Colors: custom\n"
dialog --backtitle "$BACKTITLE" \ dialog --backtitle "$BACKTITLE" \
@ -392,7 +402,8 @@ mkdir -p "$(dirname "$OUTPUT")"
printf ' "run_tui": %s,\n' "$AF_RUN_TUI" printf ' "run_tui": %s,\n' "$AF_RUN_TUI"
printf ' "components": %s,\n' "$(_words_to_json_array "$AF_COMPONENTS")" printf ' "components": %s,\n' "$(_words_to_json_array "$AF_COMPONENTS")"
printf ' "desktop_environment": %s,\n' "$(json_str "$AF_DE")" printf ' "desktop_environment": %s,\n' "$(json_str "$AF_DE")"
printf ' "apps": %s' "$(_words_to_json_array "$AF_APPS")" printf ' "apps": %s,\n' "$(_words_to_json_array "$AF_APPS")"
printf ' "shell_rc": %s' "$(json_str "$AF_SHELL_RC")"
if [[ -n "$AF_COLOR_TEXT" ]]; then if [[ -n "$AF_COLOR_TEXT" ]]; then
printf ',\n "colors": {\n' printf ',\n "colors": {\n'

View File

@ -246,6 +246,7 @@ AF_HOSTNAME=""
AF_COMPONENTS="" AF_COMPONENTS=""
AF_DE="none" AF_DE="none"
AF_APPS="" AF_APPS=""
AF_SHELL_RC="dotfiles"
AF_COLOR_TEXT="" AF_COLOR_TEXT=""
AF_COLOR_BG="" AF_COLOR_BG=""
AF_COLOR_HIGHLIGHT="" AF_COLOR_HIGHLIGHT=""
@ -263,6 +264,7 @@ load_answerfile() {
AF_COMPONENTS=$(jq -r '(.components // []) | join(" ")' "$ANSWERFILE") AF_COMPONENTS=$(jq -r '(.components // []) | join(" ")' "$ANSWERFILE")
AF_DE=$(jq -r '.desktop_environment // "none"' "$ANSWERFILE") AF_DE=$(jq -r '.desktop_environment // "none"' "$ANSWERFILE")
AF_APPS=$(jq -r '(.apps // []) | join(" ")' "$ANSWERFILE") AF_APPS=$(jq -r '(.apps // []) | join(" ")' "$ANSWERFILE")
AF_SHELL_RC=$(jq -r '.shell_rc // "dotfiles"' "$ANSWERFILE")
# Color values are optional; an empty string means "keep the repo default". # Color values are optional; an empty string means "keep the repo default".
AF_COLOR_TEXT=$(jq -r '.colors.COLOR_TEXT // ""' "$ANSWERFILE") AF_COLOR_TEXT=$(jq -r '.colors.COLOR_TEXT // ""' "$ANSWERFILE")
AF_COLOR_BG=$(jq -r '.colors.COLOR_BG // ""' "$ANSWERFILE") AF_COLOR_BG=$(jq -r '.colors.COLOR_BG // ""' "$ANSWERFILE")
@ -519,6 +521,18 @@ else
3>&1 1>&2 2>&3) || SELECTED_APPS="" 3>&1 1>&2 2>&3) || SELECTED_APPS=""
fi fi
# ── Shell RC preference ───────────────────────────────────────────────────────
if $ANSWERFILE_MODE; then
SHELL_RC="$AF_SHELL_RC"
else
SHELL_RC=$(dialog --backtitle "$BACKTITLE" \
--title " Shell Config for New Users " \
--menu "\n Should new users on this machine inherit the dotfiles' rc files?\n (Controls what gets copied to /etc/skel)\n" 13 68 2 \
"dotfiles" "Use the_miro's .zshrc / .bashrc / .vimrc from dotfiles" \
"defaults" "Skip — use system defaults for new users" \
3>&1 1>&2 2>&3) || SHELL_RC="defaults"
fi
# ── Confirmation (interactive mode only) ────────────────────────────────────── # ── Confirmation (interactive mode only) ──────────────────────────────────────
if ! $ANSWERFILE_MODE; then if ! $ANSWERFILE_MODE; then
# Build a human-readable summary of everything that will be installed so the # Build a human-readable summary of everything that will be installed so the
@ -530,6 +544,8 @@ if ! $ANSWERFILE_MODE; then
[[ "$COMPONENTS" == *"svc"* ]] && SUMMARY+=" ✦ Core services\n" [[ "$COMPONENTS" == *"svc"* ]] && SUMMARY+=" ✦ Core services\n"
[[ "$COMPONENTS" == *"shell"* ]] && SUMMARY+=" ✦ Shell setup\n" [[ "$COMPONENTS" == *"shell"* ]] && SUMMARY+=" ✦ Shell setup\n"
[[ "$DE" != "none" && "$DE" != "" ]] && SUMMARY+=" ✦ Desktop environment: $DE\n" [[ "$DE" != "none" && "$DE" != "" ]] && SUMMARY+=" ✦ Desktop environment: $DE\n"
[[ "$SHELL_RC" == "dotfiles" ]] && SUMMARY+=" ✦ Shell rc files → /etc/skel (dotfiles)\n" \
|| SUMMARY+=" ✦ Shell rc files → /etc/skel (system defaults)\n"
if [[ -n "$SELECTED_APPS" ]]; then if [[ -n "$SELECTED_APPS" ]]; then
SUMMARY+="\n Applications:\n" SUMMARY+="\n Applications:\n"
@ -831,11 +847,13 @@ if [[ -d "$HOME/.config" ]]; then
# itself, making the merge non-destructive if /etc/skel/.config already exists. # itself, making the merge non-destructive if /etc/skel/.config already exists.
sudo cp -r "$HOME/.config/." /etc/skel/.config/ sudo cp -r "$HOME/.config/." /etc/skel/.config/
fi fi
# Copy themes, shell rc files, and vimrc only if they were actually created during install.
[[ -d "$HOME/.themes" ]] && { sudo mkdir -p /etc/skel/.themes; sudo cp -r "$HOME/.themes/." /etc/skel/.themes/; } [[ -d "$HOME/.themes" ]] && { sudo mkdir -p /etc/skel/.themes; sudo cp -r "$HOME/.themes/." /etc/skel/.themes/; }
[[ -f "$HOME/.zshrc" ]] && sudo cp "$HOME/.zshrc" /etc/skel/.zshrc # Copy shell rc files to skel only if the user opted in to the dotfiles configs.
[[ -f "$HOME/.bashrc" ]] && sudo cp "$HOME/.bashrc" /etc/skel/.bashrc if [[ "$SHELL_RC" == "dotfiles" ]]; then
[[ -f "$HOME/.vimrc" ]] && sudo cp "$HOME/.vimrc" /etc/skel/.vimrc [[ -f "$HOME/.zshrc" ]] && sudo cp "$HOME/.zshrc" /etc/skel/.zshrc
[[ -f "$HOME/.bashrc" ]] && sudo cp "$HOME/.bashrc" /etc/skel/.bashrc
[[ -f "$HOME/.vimrc" ]] && sudo cp "$HOME/.vimrc" /etc/skel/.vimrc
fi
# ── Done ────────────────────────────────────────────────────────────────────── # ── Done ──────────────────────────────────────────────────────────────────────
if $ANSWERFILE_MODE; then if $ANSWERFILE_MODE; then