-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
shellHook behavior #18
Comments
Yep, there are some differences in behavior caused by shell hooks. However, the 100% correct behavior would be more complicated than the way that you described, because:
|
If you need a workaround for this particular use case, you might add these lines to your bashrc: if [ "$IN_CACHED_NIX_SHELL" ]; then
eval "$shellHook"
unset shellHook
fi Or, if you'll need just the variable, you'll have to pass it with $ OTHERVAR=201 cached-nix-shell --keep OTHERVAR cached-shell.nix |
Oh, I see, things are indeed more complicated than I thought. Thanks for explaining. I wonder though if it wouldn't still be better/more expected to not cache shellHook and run it upon invocation. It certainly is what I expected, and from what I understand cached-nix-shell is already insensitive to environment variables which might alter what setuphook does (so your examples are with |
Given the following
cached-shell.nix
:This is how
nix-shell
behaves:And this is
cached-nix-shell
(theecho
command outputs nothing both with a cached shell and when caching it the first time):So I think there's a difference in behavior. Would it be correct to say that the correct behavior for
cached-nix-shell
should be:shellHook
attribute. However, take care to cache dependencies that might be brought in by${some-nix-var}
inshellHook
's body.shellHook
everytimecached-nix-shell
runs.Thanks in advance!
The text was updated successfully, but these errors were encountered: