I am new here and was struggling a bit with setting fish as my shell across terminals or programs that embed terminals (kitty, pycharm, vs code) but I was worried to change my system login shell away from ZSH (macOS) in case this was going to cause some issues.
I came up with the following solution after googling, reading, and trial and error around changing my shell. Since I am a novice here, just checking that this makes sense (specifically the /etc/profiles/per-user/$USER/bin/fish) or if I should structure it in another way, I saw usage of pkgs.fish in some examples as well. This was from the gentoo wiki and modified to this version.
You also want to make sure that your zshrc (BEFORE any of you shell switching logic) has something similar to this in order to prevent scripts running bash from switching to fish
# Commands that should be applied only for interactive shells.
[[ $- == *i* ]] || return
I think the main differences to your approach are
No need to check if the fish binary is in your home-manager folder if you use the nixpkgs reference directly.
The other approach still allows you to start bash if your current shell is already fish.
Great points and feedback! I tried to use the example but it was tailored for bash and I am on macOS hence zsh is default - didn’t want to change login shell to bash.
On nixos, ZSH does not have the option “interactiveShellInit” (for bash from the doc you linked) so I was looking for alternative ways to do it and settled on my option. I also didn’t have access to shopt on zsh and didn’t spend time to find an alternative command.
I was mostly curious about using this in my approach:
/etc/profiles/per-user/$USER/bin/fish
vs.
${pkgs.fish}/bin/fish
I thought ${pkgs.fish} points to the specific version and not a link or alias so I was trying to use my user installed version. I can play around with this a bit more though.
They should be exact same version of fish, right? Because both of the fish references will be managed by nix home-manager/ nix-darwin whatever you are using.
So I do not understand why you would want to go thorough yet another symlink, to the exact same fish binary. But if you think you have a reason for referencing /etc/profiles. If it works it works.
I went with your suggestions. My confusion came with the multiple ways you can install / enable the shell.
I had installed it to my systemPackages, set the programs.fish.enable = true; in my configuration and also had it installed for my user by setting it to be enabled with home manager.
I’ve just removed the install with systemPackages and used ${pkgs.fish} in my zsh startup script, thanks!