This is, as glyph pointed out a while back, an "extremely specific complaint", but here's the short version:
If you use nix and direnv, it is natural to have a .envrc
that contains use flake
; it sets up your local development environment in a friendly way for your tools. You might be tempted to include that .envrc
file in your repository, so that you don't have to enter that single line of text in any new clone.
I am asking you, please, do not do that second thing.
I use Direnv extensively and have for years, but I don't use Nix, and am not likely ever to (in part because I'm a macOS user, and Nix is still not friction-free there, but also because I just don't want to). I also clone a lot of open source repositories with an eye to making small contributions to them. When one of them contains a checked-in .envrc
file, though, I'm braced for friction.
What that means is that the first interaction I have with your code is a speedbump in every single tool I use. My editor reads .envrc
files, so I see errors there. My shell does, too, so that fails. Unless you perform the workaround I describe in another post, every direnv invocation will either fail, or I'll have to maintain a permanently dirty working copy of your repository (which is, in fact, a lot harder if one is trying out jujutsu).
If it helps to convince you, Direnv itself is described as "Built with Nix" and has a flake configuration, but they don't check in their .envrc
; that's not where the file belongs.
So, please stop. If you've added it, please consider a PR to remove it so that future contributors can use the tools that make sense for them.
Edit: To be a bit more constructive...
Someone on lobste.rs pointed out that I am not being constructive in this post, and that's a valid point. If you want to encourage .envrc
use in your projects, can I recommend instead that you add .envrc.defaults
to your repository? Your README can recommend that new users run echo 'source_env_if_exists .envrc.defaults' | tee -a .envrc && direnv allow
; that'll set up the development environment you recommend, but allow people who use different tools to maintain their own environments. Then, add .envrc
to .gitignore
and happy hacking!
Edit: Someone on Mastodon pointed out that this has been actively discussed in the issues for the direnv project, as well as by the Nix project.
You can reply to this post via Mastodon:
Waiting to load comments