Skip to content

Commit ad9f64f

Browse files
committed
Make default shell to zsh
1 parent 033def4 commit ad9f64f

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

.config/home-manager/home.nix

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,23 @@
2121

2222
home.sessionVariables = userConfig.env;
2323

24+
# Set zsh as default shell on activation
25+
home.activation.make-zsh-default-shell = lib.hm.dag.entryAfter [ "writeBoundary" ] ''
26+
# if zsh is not the current shell
27+
PATH="/usr/bin:/bin:$PATH"
28+
ZSH_PATH="/home/${user}/.nix-profile/bin/zsh"
29+
if [[ $(getent passwd ${user}) != *"$ZSH_PATH" ]]; then
30+
echo "setting zsh as default shell (using chsh). password might be necessary."
31+
if grep -q $ZSH_PATH /etc/shells; then
32+
echo "adding zsh to /etc/shells"
33+
run echo "$ZSH_PATH" | sudo tee -a /etc/shells
34+
fi
35+
echo "running chsh to make zsh the default shell"
36+
run chsh -s $ZSH_PATH ${user}
37+
echo "zsh is now set as default shell!"
38+
fi
39+
'';
40+
2441
# Let Home Manager install and manage itself.
2542
programs.home-manager.enable = true;
2643

0 commit comments

Comments
 (0)