Closed terlar closed 4 years ago
I ended up adding this to my interactive shell init:
if set -q IN_NIX_SHELL
function __direnv_export_eval
# Don't trigger within nix-shell
end
end
Seems to work, not sure if there is interest in having that as part of any-nix-shell. Otherwise feel free to close.
Does the same issue arise when using direnv+lorri in bash and using the normal nix-shell
?
Perhaps, I guess I never really realized since I am not using bash, just checked, seems like direnv hooks are not setup properly for the bash environment, so they don't execute (at all). Which could explain why I have not experienced this before with regular nix-shell+bash.
Just seems a bit unfortunate with the direnv unloading which happens on directory switch, that it also unloads all the env vars that has been setup by the nix-shell itself.
seems like direnv hooks are not setup properly for the bash environment
Do you have the direnv hook in ~/.bashrc
?
Nope, I don't even have a ~/.bashrc
. I installed direnv via home-manager programs.direnv.enable = true;
. That was enought for fish to pick it up, but guess bash requires some more love. I'm using NixOS as well btw.
Yes but I thought you also attempted to reproduce the issue with bash. If it also arises with bash (i.e. nix-shell without any-nix-shell), then it's only a direnv issue.
Ah, okay, sorry for the confusion. I will see if I can achieve that and we will know where to go from there.
So yes this also happens with bash when I have configured it to also have the direnv hooks. So I guess this is more of an issue with direnv+nix.
Thanks for checking this out!
I am not sure this should be an issue with direnv or any-nix-shell but it manifests when using both together.
So if I am using direnv+lorri in a project and within this project I want to launch another nix-shell. Then when I am using any-nix-shell with fish the direnv unload hooks will fire as soon as I switch directory, making me loose all the PATH:s etc that the nix-shell had setup.
I wonder if there is a way to make these work together somehow.