docs: Update direnv
docs for Nix and remove .envrc
#3790
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.
This PR reverts the addition of
.envrc
from #3745. It also updates the docs to mention how the reverted functionality can be enabled.Note: I'm open to alternative solutions for this, but I haven't found any good ones.
The motivation behind this change is that
direnv
has no alternative point of entry than.envrc
which means that if we commit an.envrc
to the repo, it'll be hard(er) to maintain an.envrc
containing personal preferences (due to there constantly being a file in the repo with local changes and you have to be very careful not to commit, could contain secrets and what not).The motivation is also selfish, to a degree. For me,
direnv
is a tool to ensure the environment is set up the way I want it to be, and may vary from system to system or project.There is discussion ongoing in direnv/direnv#556 that would fix/allevate the issue.
Potential workarounds were considered:
git
to ignore changes to.envrc
or to never check out the file (after some research, doesn't seem possible)direnv
to source an alternative fileThe latter would be possible to some degree, but has some unwanted consequences, the following workarounds do exist, however:
source_env_if_exists .envrc.local
to the.envrc
in the repo~/.config/direnv/direnvrc
Option 1 could work, but the sourced file stays outside the security framework (
direnv allow
), in theory a malicious author could try to add a.envrc.local
to this repo which would lead to arbitrary code execution on any machine that has allowed the original.envrc
once the new file is pulled.Option 1 also has the downside of enabling Nix if it's installed (which may not be wanted), which brings us to option 2.
For option 2 the user could add this to their
~/.config/direnv/direnvrc
:However, this solution seems janky. Again we're sourcing a file outside the security framework (but at least we can use an obfuscated name, so the above mentioned security implication is mitigated to some defree).
A second observation of this is that
.envrc.private
will be sourced immediately, so it could still be overridden by values in.envrc
. There may also be other side-effects of sourcing in thedirenvrc
that I'm not aware of.