Hi,
the starship command prompt uses the ‘IN_NIX_SHELL’ variable to show when the shell is a nix-shell. However, when using the new ‘nix shell’ command, it seems that the ‘IN_NIX_SHELL’ environment variable is not being set.
Is there a way to tell when one is in a ‘nix shell’ environment?
Thanks
I found this PR to set IN_NIX_SHELL
also for nix shell
but it looks like it was rejected.
One of the comments suggests looking for a nix store entry in PATH
to determine if you are using nix shell
.
1 Like
Thanks, so I guess starship needs to implement a workaround. For now I will just set SHLVL in starship.
In case somebody hitting this, there’s a hack implemented in starship to prompt ‘nix shell’
starship:master
← jjant:jjant/support-nix-shell
opened 01:03PM - 15 Dec 22 UTC
#### Description
Closes #2950.
Adds two options for `nix_shell`:
- `heurist… ic`: Enables detection of `nix shell` with the heuristic described below (default: disabled)
- `unknown_msg`: Like `pure/impure_msg` for when we can't detect which shell type it is
#### Motivation and Context
The current `nix_shell` module only works with `nix-shell`, not `nix shell`.
There's no straightforward way to detect if we're in a `nix shell` yet, so I've used a workaround that checks if we have a nix store path in our `PATH` to detect if we're in a `nix shell`.
#### How Has This Been Tested?
I've added tests in the `nix_shell` module.
#### Checklist:
- [x] I have updated the documentation accordingly.
- [x] I have updated the tests accordingly.
Just need to set heuristic = true
under nix_shell