Set another shell as the default for nix-shell?

When I do nix-shell p <package name>, it starts a bash shell despite my terminal using fish, and with users.defaultUserShell = [pkgs.fish]; in my config.

I’ve long had an alias for this: alias nix-zshell='nix-shell --run zsh'.

Or for fish: alias nix-fshell='nix-shell --run fish'.

nix-shell was designed to “start an interactive shell based on a Nix expression”, and those are built using bash. That’s why it ignores the default.

You could use nix-your-shell (GitHub - MercuryTechnologies/nix-your-shell: A `nix` and `nix-shell` wrapper for shells other than `bash`) to keep your current shell.

1 Like