Always run my shell in `nix-shell`, `nix develop`, et al.?

I use zsh as my shell, but bash seems to be very much ingrained in the Nix ecosystem. All that being said, is there a way to configure tools like nix-shell, nix run, and nix develop to drop me into a zsh instead of bash?

Currently, I have defined an alias nixs='nix-shell --command zsh'. Though this works, it has always felt ugly, like I am throwing away the ability to use --command for its true purpose, while also training my muscle memory to use a non-standard command to obtain a development shell.

Otherwise, I use the “correct” command and then manually invoke zsh, but this feels wrong as well.

Now that I am trying to learn to use Flakes and the experimental nix command, this problem has come to a head: I’d like to stop using hacky solutions to this and figure out if there’s one true way to accomplish what I’m after.



There is the project

Personally, I use direnv which auto-loads nix-shell, and has a nice side-effect of simply editing your current shell’s environment instead of loading a new shell, leaving me in my zsh shell. Combine this with for shell caching and flake support and it seems ideal to me, but may not work for you depending on how you use it.


Related Nix issue


@gh0st, thanks for those suggestions. I have been meaning to try direnv or lorri for a while now; this may be the final kick I need to actually do it.

@FRidh, I was not aware of that issue, so thanks for pointing it out. Do you know if there is some way for me to help move that effort forward?


1 Like