Fix infinite loop that happens when using direnv #1667
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.
Do you know about https://direnv.net/?
It is a nice tool that activates nix flake dev shell when entering project directory and at the same time preserving current shell (instead of executing bash subshell).
Unfortunately it enters infinite loop when shellHook executes inner zsh subshell.
(Direnv activates the development shell, which calls shell hook and creates subshell, in which direnv activates the development shell, which calls shell hook and creates subshell, and so on... )
I think that running zsh in a shell hook is a wrong direction. Most probably
direnvis the right solution to your problem.In short about
direnv:set proper NixOS options (or see installation instructions for other OSes)
create
.envrcfile with contentuse flakein the project root directory"allow" direnv to run project's
.envrcautomatically by executingdirenv allowin the project root directorynow when entering project directory the "dev shell mode" will be activated (but without running subshell, and thus preserving current shell)
Important
Removes
shellHookinflake.nixto fix infinite loop withdirenvby preventingzshsubshell execution.shellHookinflake.nixthat executedzsh, which caused an infinite loop withdirenv.direnvby preventing subshell execution.This description was created by
for a532069. It will automatically update as commits are pushed.