Expose NIX_SHELL_LEVEL to make it easy to track how many shells deep you are #826

Closed
opened 2025-05-10 19:40:57 +00:00 by dwt · 1 comment

When working with nix shells in development environments, I often accidentally close the windows, by closing the last shell because it is hard to see how many levels deep you are in a nix shells.

This is exacerbated by using direnv, so even the outermost shell becomes a nix shell, thus loosing the ability to stop closing shells as soon as it is not a nix shell anymore.

Describe the solution you'd like

Ideally I would like some metadata that allows me to show what has been activated in this nix-shell, but I would also settle for a simple counter, so I can at least see when I am in the last one.

Describe alternatives you've considered

Something like NIX_ACTIVATED_PACKAGES might be nice, but perhaps only in addition to NIX_SHELL_LEVEL

What do you think? Is there already something like this that I just missed?

## Is your feature request related to a problem? Please describe. When working with nix shells in development environments, I often accidentally close the windows, by closing the last shell because it is hard to see how many levels deep you are in a nix shells. This is exacerbated by using direnv, so even the outermost shell becomes a nix shell, thus loosing the ability to stop closing shells as soon as it is not a nix shell anymore. ## Describe the solution you'd like Ideally I would like some metadata that allows me to show what has been activated in this nix-shell, but I would also settle for a simple counter, so I can at least see when I am in the last one. ## Describe alternatives you've considered Something like `NIX_ACTIVATED_PACKAGES` might be nice, but perhaps only in addition to `NIX_SHELL_LEVEL` What do you think? Is there already something like this that I just missed?
Member

This issue was mentioned on Gerrit on the following CLs:

  • commit message in cl/4657 ("nix-shell: Add NIX_SHELL_LEVEL variable")
<!-- GERRIT_LINKBOT: {"cls": [{"backlink": "https://gerrit.lix.systems/c/lix/+/4657", "number": 4657, "kind": "commit message"}], "cl_meta": {"4657": {"change_title": "nix-shell: Add NIX_SHELL_LEVEL variable"}}} --> This issue was mentioned on Gerrit on the following CLs: * commit message in [cl/4657](https://gerrit.lix.systems/c/lix/+/4657) ("nix-shell: Add NIX_SHELL_LEVEL variable")
pennae added this to the 2.95 milestone 2025-12-01 14:51:31 +00:00
raito closed this issue 2025-12-01 15:09:15 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
lix-project/lix#826
No description provided.