A fast, persistent use_nix/use_flake implementation for direnv [maintainer=@Mic92 / @bbenne10]
Go to file
Jörg Thalheim 82711395ac
README: mention lorri
fixes #9
2020-04-09 06:32:05 +01:00
.github/workflows add tests 2020-04-01 16:12:48 +01:00
tests add tests 2020-04-01 16:12:48 +01:00
ci.nix add tests 2020-04-01 16:12:48 +01:00
default.nix Fix nix-instantiate substituted path 2020-04-09 12:05:23 +08:00
direnvrc replace shebang by shellcheck directive 2020-04-01 16:08:58 +01:00
LICENSE Initial commit 2019-09-27 08:43:48 +01:00
README.md README: mention lorri 2020-04-09 06:32:05 +01:00
shell.nix add tests 2020-04-01 16:12:48 +01:00

nix-direnv

Test

A fast, persistent use_nix implementation for direnv. Prominent features:

  • significantly faster after the first run by caching the nix-shell environment
  • prevents garbage collection of build dependencies by symlinking the resulting shell derivation in the user's gcroots (Life is too short to loose your build cache of your project if you are in a plane without internet connection)

USAGE

$ git clone https://github.com/nix-community/nix-direnv $HOME/.nix-direnv

Then source the direnvrc from this repository in your own .direnvrc

# put this in ~/.direnvrc
source $HOME/.nix-direnv/direnvrc

For derivations to persist garbage collection, set the following in nix.conf:

keep-derivations = true
keep-outputs = true

Known Bugs

At the moment nix-direnv depends on gnugrep and a modern bash version. This might lead to problems on macOS. As a work-around we suggest to install direnv/grep via nix or homebrew.

Why not using lorri instead.

Lorri causes large CPU load when $NIXPKGS is pointed to a directory, i.e. a git checkout. This is because it tries to watch any referenced nix file and re-evaluates if those changes. Nix-direnv comprises between performance and correctness and only reevaluate direnv if either the project-specific default.nix / shell.nix changes or if there is a new commit added to nixpkgs. A re-evaluation can be also triggered by using touch shell.nix in the same project. Also nix-direnv does not require additional software besides direnv + nix i.e. a daemon and the function could be included into the project itself.