Trying to use a flake with direnv
to enable a development environment, I get the error
store path '/nix/store/<hash>-<my-flake-name>' is not allowed to have references
However, an explicit nix develop
succeeds, and thereafter, direnv
also succeeds.
Given that direnv
fails with this error every time I check out a different commit, or modify (or even touch
) the flake, I have got into the habit of using the hacky workaround
nix develop -c true && cd - && cd -
where
-
nix develop
gets around the error and puts me in a state whichdirenv
can handle - the two
cd -
s nudgedirenv
into action to that it loads the new environment.
This works and gets me around the error, but
- it’s very annoying
- collaborators will be stupmed when trying to use this environment and are faced with this error
I observe this behaviour on Linux, but (if memory serves me correctly, I don’t have direct access to a Mac) not on Darwin.
Can you suggest what might be causing this, and how to get rid of the problem?
A sample repository that exhibits this behaviour can be found here. To trigger the error:
- Ensure you have
direnv
enabled. -
cd
into the repository root. - Approve with
direnv allow
.
The error should appear.
After getting around the error with nix develop -c true && cd - && cd -
it can be triggered again by any of these actions:
touch flake.nix
- modifying the flake
- checking out any other commit