fix(install): normalize empty keyboard variants
All checks were successful
Check / eval (push) Successful in 3m18s
All checks were successful
Check / eval (push) Successful in 3m18s
Treat the picker-only (none) row as an empty XKB variant at the shared input boundary and again in the template patcher. Guard the real downstream output and console keymap, and carry the sentinel through the offline installer VM. Verified: V0 full flake evaluation plus shell/Python/Nix/diff checks; V1 installer-keyboard, installer-safety, and template-SoT builds; V2 full KVM offline LUKS+swap install and themed first boot. No V3 required.
This commit is contained in:
@@ -222,9 +222,14 @@ else
|
||||
KB_VARIANT=$( { echo "(none)"; localectl list-x11-keymap-variants "$KB_LAYOUT" 2>/dev/null; } \
|
||||
| gum filter --placeholder "variant for $KB_LAYOUT (pick '(none)' for the default)" \
|
||||
|| echo "(none)")
|
||||
[[ "$KB_VARIANT" == "(none)" ]] && KB_VARIANT=""
|
||||
fi
|
||||
fi
|
||||
# `(none)` is gum's display-only sentinel, never an XKB variant. Keep the
|
||||
# normalization at the common boundary so interactive and unattended installs
|
||||
# cannot write it into either generated Nix file.
|
||||
if [[ "$KB_VARIANT" == "(none)" ]]; then
|
||||
KB_VARIANT=""
|
||||
fi
|
||||
[[ "$USERNAME" =~ ^[a-z_][a-z0-9_-]*$ ]] || fail "Invalid username '$USERNAME'."
|
||||
[[ -f "/usr/share/zoneinfo/$TIMEZONE" || -e "/etc/zoneinfo/$TIMEZONE" ]] \
|
||||
|| timedatectl list-timezones 2>/dev/null | grep -qx "$TIMEZONE" \
|
||||
|
||||
@@ -32,6 +32,12 @@ def nix_str(s: str) -> str:
|
||||
)
|
||||
|
||||
|
||||
def keyboard_variant(v: dict) -> str:
|
||||
"""Return the XKB value, never the picker's display-only sentinel."""
|
||||
variant = v.get("keyboardVariant") or ""
|
||||
return "" if variant == "(none)" else variant
|
||||
|
||||
|
||||
def replace_once(text: str, old: str, new: str, label: str) -> str:
|
||||
if old not in text:
|
||||
sys.exit(f"patch-template: missing placeholder for {label}: {old!r}")
|
||||
@@ -75,7 +81,7 @@ def patch_flake(text: str, v: dict) -> str:
|
||||
|
||||
def patch_home(text: str, v: dict) -> str:
|
||||
layout = nix_str(v["keyboardLayout"])
|
||||
variant = nix_str(v.get("keyboardVariant") or "")
|
||||
variant = nix_str(keyboard_variant(v))
|
||||
text = replace_once(
|
||||
text,
|
||||
' nomarchy.keyboard.layout = "us";',
|
||||
@@ -213,7 +219,7 @@ def patch_system(text: str, v: dict) -> str:
|
||||
text = replace_once(
|
||||
text,
|
||||
' services.xserver.xkb.variant = "";',
|
||||
f' services.xserver.xkb.variant = "{nix_str(v.get("keyboardVariant") or "")}";',
|
||||
f' services.xserver.xkb.variant = "{nix_str(keyboard_variant(v))}";',
|
||||
"xkb variant",
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user