From 0c292694f37f107629b5287f96ebb945ff764b68 Mon Sep 17 00:00:00 2001 From: sommerfeld Date: Fri, 22 May 2026 10:41:22 +0100 Subject: fix(just): chsh to nix-managed zsh after nix-switch MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit zsh now lives in nix/common.nix instead of meta/base.txt. Removing the pacman zsh package leaves /etc/passwd dangling at /usr/bin/zsh, so new login terminals die with 'shell not found'. Mirror the chsh logic from nix/bootstrap.sh (which only runs on the VM during first-time provisioning) into the nix-switch recipe so every `just sync` / `just init` re-asserts the login shell — and the host gets the same treatment as the VM. Idempotent: skips when the shell already matches, skips when ~/.nix-profile/bin/zsh is missing (pre-bootstrap state). --- justfile | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/justfile b/justfile index a1cb7b3..dec9200 100644 --- a/justfile +++ b/justfile @@ -42,6 +42,20 @@ nix-switch: nix --extra-experimental-features 'nix-command flakes' \ run home-manager/master -- \ switch --impure --flake "{{ justfile_directory() }}/nix#${profile}" -b backup + # Ensure login shell points at the home-manager-managed zsh. Without + # this, removing zsh from meta/base.txt (now provisioned via nix) + # leaves /etc/passwd dangling at /usr/bin/zsh and new terminals die. + # Idempotent: only acts when current login shell differs. + NIX_ZSH="$HOME/.nix-profile/bin/zsh" + if [ -x "$NIX_ZSH" ]; then + if ! grep -qxF "$NIX_ZSH" /etc/shells 2>/dev/null; then + echo "$NIX_ZSH" | sudo tee -a /etc/shells >/dev/null + fi + current_shell="$(getent passwd "$USER" | cut -d: -f7)" + if [ "$current_shell" != "$NIX_ZSH" ]; then + sudo chsh -s "$NIX_ZSH" "$USER" + fi + fi # ═══════════════════════════════════════════════════════════════════ # Updates -- cgit v1.3.1