Using home-manager to control default user shell?

Hi everyone! Is it possible to use home-manager to control my default user shell? Something like chsh, but made Nix-y?

I wasn’t able to find anything searching on google or looking through the home-manager docs. I’m running home-manager on Ubuntu.

1 Like

To follow up on this: It also seems like it’s not possible to make chsh use a home-manager-installed shell:

$ chsh -s /home/skainswo/.nix-profile/bin/zsh
Password: 
chsh: /home/skainswo/.nix-profile/bin/zsh is an invalid shell

Is there any way to use a home-manager-managed shell as my default login shell?

EDIT: Fix is to add /home/skainswo/.nix-profile/bin/zsh as a line to /etc/shells.

EDIT: Fix is to add /home/skainswo/.nix-profile/bin/zsh as a line to /etc/shells .

I’ve did this for a nix install on Debian WSL, and while it works, I have found it is incomplete, since zsh does not source ~/.profile (NB this friendly helpful graph on which startup files sh, bash and zsh source depending on if the shell is login/interactive).

The nix installer adds a line to .profile that, among other things, add ~/.nix-profile/bin/ to $PATH, so if you chsh you nix-installed zsh, it won’t be able find your other nix-installed programs. Luckily, this is easy to fix; just add the additional line from .profile to .zprofile:

if [ -e $HOME/.nix-profile/etc/profile.d/nix.sh ]; then . $HOME/.nix-profile/etc/profile.d/nix.sh; fi

I think that should fix it, but it wouldn’t surprise me if I am missing something, as with anything involving the shell.