Skip to content

Conversation

@scaryrawr
Copy link

Description

When using nix shell, the IN_NIX_SHELL variable is not set.

A common workaround is to check if /nix/store/ is on the PATH.

Motivation and Context

nix shell does not set $IN_NIX_SHELL

Closes #542

Screenshots (if appropriate)

How Has This Been Tested

  • I have tested using Linux.
  • I have tested using MacOS.

Checklist

  • I am ready to update the wiki accordingly.
  • I have updated the tests accordingly.

When using `nix shell`, the `IN_NIX_SHELL` variable is not set.

A common workaround is to check if `/nix/store/` is on the PATH.
@scaryrawr scaryrawr requested a review from IlanCosman as a code owner March 28, 2025 14:29
@calops
Copy link

calops commented Mar 31, 2025

A common workaround is to check if /nix/store/ is on the PATH.

Is that really a common workaround? Wouldn't that always identify a NixOS environment as a nix shell?

@scaryrawr
Copy link
Author

A common workaround is to check if /nix/store/ is on the PATH.

Is that really a common workaround? Wouldn't that always identify a NixOS environment as a nix shell?

Ah, maybe not common, but it is how starship treats it. They have an unknown option vs pure/impure where if they're in an NixOS environment.

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

Successfully merging this pull request may close these issues.

Detect nix shell (in addition to nix-shell)

2 participants