Fix pypi2nix failing to spawn shell #20
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I made this change to get pypi2nix working as I experienced similar issues as in #15
The way I managed to work around this is to introduce a new env variable NIX_EXECUTING_SHELL which (as the name says) holds the shell executable from which nix-shell was executed. It is then used by the buildShellShim as the shell. to be spawned in case of interactive invocations.
The main problem with pypi2nix was that it executes nix-shell without zsh on PATH which made the shim fail to run, it also unsets $SHELL so now with NIX_EXECUTING_SHELL empty, nothing gets executed and for such situations a bash shell stays open as a. result.
Note: Although this is meant to fix an issue with pypi2nix I suspect this to also work on other projects which use nix-shell from a clean process.