DEV Community

Some direnv best practices. Actually just one.

Gavin Panella on November 04, 2019

I use direnv to configure the environment in most projects I'm working on. In my day job a few projects use direnv to load Nix environments for dev...
Collapse
 
onetom profile image
Tamas Herman

A lot of time has passed since this article was written, so here are a few updates:

A faster, persistent implementation of direnv's use_nix, to replace the built-in one.
github.com/nix-community/nix-direnv

and

buffer-local direnv integration for Emacs
github.com/purcell/envrc

Collapse
 
onetom profile image
Tamas Herman

I'm using envrc.el (instead of direnv.el) for a few weeks now and it's a smoother, snappier experience overall, so I highly recommend envrc.el!

Collapse
 
farazshaikh profile image
Faraz

Also see
melpa.org/#/direnv
direnv integration with emacs.

Useful when you want to binaries from nix tooling for code completion formatting etc.

Collapse
 
arjv27 profile image
arj

Holy shit, super useful -- finding easy to understand documentation on nix workflows seems impossible.

Collapse
 
farazshaikh profile image
Faraz

#cat ./.envrc
DIRENV_LOG_FORMAT="" source <(direnv apply_dump .envrc.cache)

This silences the environment diff that would otherwise get printed after every shell command.

Collapse
 
con-f-use profile image
con-f-use

forking background processes from .envrc (be prepared to be eaten by a grue many times before you get it right)

I never managed. How do you do it?