Closed golddranks closed 3 years ago
Unfortunately I can't debug on MacOS.
By the way: Did you try lorri? It's much better than any-nix-shell.
@golddranks, it looks like the main issue you are having isn't related to any-nix-shell
but rather that you haven't sourced the ~/.nix-profile/etc/profile.d/nix.sh
from Fish. You need to do that before any-nix-shell
can do it's thing.
As you point out, it's not straight forward to do that since it's a Bash shell script. The easiest way I've found to do this is to use the Fish plugin fenv
. With the plugin installed, you can run fenv source ~/.nix-profile/etc/profile.d/nix.sh
to get Nix working in Fish.
On my setup, I install fenv
through Nix,
https://github.com/malob/nixpkgs/blob/27b6d933eb08487ce8fa76e1cd76b2804535bc4e/overlays/myenv.nix#L18
and add it to my Fish config and source the Nix profile like so: https://github.com/malob/config.fish/blob/master/conf.d/00-nix.fish
Adding to @malob if anyone comes by later:
I've used fenv
, bax
and now replay
fish functions do be able to source bash files from fish. Since nix doesn't give a way to start from fish natively, we need to source a bash file from fish and keep the env. In my config.fish I now have:
# Nix
if test -e '/Users/viktor/.nix-profile/etc/profile.d/nix.sh'
set -x NIX_PATH $NIX_PATH $HOME/.nix-defexpr/channels
replay source '/Users/viktor/.nix-profile/etc/profile.d/nix.sh'
end
This bootstraps nix within my fish shell. And I think this is what OP is really asking about.
This project here however is to continue to use fish or whatever besides bash when running nix-shell which is another thing entirely.
I came here now because I want just that. I'm trying out lorri now but I have the need to debug by just running a simple nix-shell at times and I still want to stay in fish. So thanks!
I think this issue can be closed :)
I'm on MacOS and fish, installed from homebrew.
I installed Nix, but it doesn't work on fish by default, because the init script for the shell is bash.
I installed this package and added
any-nix-shell fish --info-right | source
to my~/.config/fish/config.fish
, and restarted the shell, but it doesn't seem to do anything:The output of
$HOME/.nix-profile/bin/any-nix-shell fish --info-right
seems to produce sensible output though:If I launch bash and source
~/.nix-profile/etc/profile.d/nix.sh
everything seems to work, so the Nix itself isn't broken.