Skip to content
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

nix run doesn't set IN_NIX_SHELL #2020

Closed
ElvishJerricco opened this issue Mar 28, 2018 · 10 comments
Closed

nix run doesn't set IN_NIX_SHELL #2020

ElvishJerricco opened this issue Mar 28, 2018 · 10 comments
Assignees

Comments

@ElvishJerricco
Copy link
Contributor

Title. My shell prompt is set to look different when IN_NIX_SHELL is set, and I have nix-shell aliased to include my prompt. Since nix run doesn't set IN_NIX_SHELL, I often have a hard time remembering if my shell is a nix run or not.

@edolstra
Copy link
Member

It's not clear whether it should set IN_NIX_SHELL, because nix run serves a different purpose than nix-shell (it doesn't provide a development environment).

@ElvishJerricco
Copy link
Contributor Author

@edolstra I guess that just depends on the intended semantics of IN_NIX_SHELL, and whether we plan to eventually have a mode of nix run for development environments.

Regardless, at least something should be set.

@shlevy shlevy added the backlog label Apr 1, 2018
@shlevy shlevy self-assigned this Apr 1, 2018
@ElvishJerricco
Copy link
Contributor Author

I've since found that $SHLVL is more appropriate for what I was using $IN_NIX_SHELL for. I'll close this, as it doesn't seem to be desired.

@giodamelio
Copy link

Just running this into myself, it would be nice to have some way to tell.

@ElvishJerricco
Copy link
Contributor Author

@giodamelio Does SHLVL help? I found it useful for more than just nix run; now I know any time I'm in a nested shell, not just a nix run.

@giodamelio
Copy link

giodamelio commented Sep 12, 2018 via email

@fgaz
Copy link
Member

fgaz commented Jan 28, 2020

I ran into this too. I have different prompts for different kinds of subshells, but I have no way to tell the difference from nix run and a simple subshell

@timor
Copy link
Member

timor commented Feb 14, 2020

Couldn't nix run set a different variable, let's say IN_NIX_RUN, or have it's own nesting counter?

@pinpox
Copy link
Member

pinpox commented Aug 4, 2021

Couldn't nix run set a different variable, let's say IN_NIX_RUN, or have it's own nesting counter?

+1 for this. I'd like to have some way to display it in the prompt e.g. when entering a shell with nix shell 'nixpkgs#hello'
to fix this starship/starship#2950

@fgaz
Copy link
Member

fgaz commented Aug 4, 2021

Related: #3862

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants