2 Commits
Author SHA1 Message Date
9p4andGerrit Code Review 8f871210b5 Merge "Detect if in Nix3 shell" into main 2025-03-09 17:45:14 +00:00
Ersei Saggi 7928669ef9 Detect if in Nix3 shell
This replicates behaviour found in the Nix2 commands, where IN_NIX_SHELL
is set. This is for shells to determine whether they are inside of a
Nix3 shell, and set a custom prompt accordingly.

For example, Fish's Tide prompt framework checks for that environment
variable and displays it in the prompt, indicating that the shell is in
a Nix environment.

This is not new behaviour, and the old Nix2 commands set the variable.

If the shell that is created is a "pure" shell, ie --ignore-environment
is passed, then IN_NIX_SHELL will be set to "pure". However, "nix
develop" will always create an impure environment.

Replicated from my Nix PR: https://github.com/NixOS/nix/pull/8885

Change-Id: I695cdc336f76541940a302835124fe7d8f7f39b2
Signed-off-by: Ersei Saggi <vcs@ersei.net>
2025-03-07 07:45:08 -05:00