Repository navigation
fix: preserve local direnv settings - #26122
Conversation
Load an ignored .envrc.local after the shared Nix environment so contributors can keep machine-specific settings without modifying tracked files. Document the Nix, direnv, and local override workflow in the development environment guide. Fixes apache#26101.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #26122 +/- ##
========================================
Coverage 82.73% 82.74%
========================================
Files 1147 1147
Lines 449459 449767 +308
Branches 449459 449767 +308
========================================
+ Hits 371864 372148 +284
- Misses 54936 54947 +11
- Partials 22659 22672 +13 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
| `direnv allow` from the repository root to load it automatically. | ||
|
|
||
| Put machine-specific direnv settings in `.envrc.local`. This file is ignored by | ||
| Git and loaded after the shared Nix environment so that local settings take |
There was a problem hiding this comment.
Could we add a short migration note for contributors who already have personal settings in .envrc? They should move those settings into .envrc.local rather than copying the entire shared file, which could duplicate use flake.
There was a problem hiding this comment.
Let me know how the update reads to you
|
@kosiew addressed + added |
|
🚀 |
|
There are 3 issues with this:
|
|
Thanks @toastal, fair points. This PR is already merged, so I'll follow up. You're right about the security issue: direnv allow approves only the top-level .envrc. That means .envrc.local (and parent .envrc files loaded through source_up_if_exists) run without being re-approved. I agree with option 3: untrack .envrc and add it to .gitignore. That also fixes #26101, which only happened because .envrc became tracked. It removes the need for .envrc.local and the flake/nix assumption too. The docs can just say echo 'use flake' > .envrc && direnv allow. A shell.nix for stable Nix users also sounds good. @VVKot, what are your thoughts on this? |
|
Thanks for the callouts @toastal! @kosiew - I had a different line of thinking here. (1) is actually a few different things. Yes, flakes are technically experimental. All major upstream projects have a flake by now though: nix, NixOS, home manager, hardware. nix-darwin says
That one's more important - I did check that (2) (3) Yes, see the issue attached / direnv guidance that I followed. I think it does provide value - as mentioned in the original PR, there is under-appreciated value in having things "just work". Ghostty maintainers say it well here https://ghostty.org/docs/config#zero-configuration-philosophy. As you've said, the security issue is "potential", and the attack vector is "someone is able to modify a file on disk on your machine" which sounds more concerning than lack of checks for loading nested @kosiew on (3) specifically - happy to go with |
Which issue does this PR close?
Closes #26101 , which was introduced in #26005. cc @kumarUjjawal @kosiew
What changes are included in this PR?
Load an ignored .envrc.local after the shared Nix environment so contributors can keep machine-specific settings without modifying tracked files.
Document the Nix, direnv, and local override workflow in the development environment guide.
Following recommendation from direnv: https://github.com/direnv/direnv/blob/e24ea74873aff78d5e371c85061dc7fafdeedd5a/README.md#quick-demo
Are there any user-facing changes?
No.