A fast, persistent implementation of direnv's use_nix and use_flake for caching Nix shell environments.
nix-direnv is a fast, persistent implementation of direnv's `use_nix` and `use_flake` functions for Nix-based development environments. It solves the problem of slow shell loading and lost build caches by caching evaluated environments and protecting dependencies from garbage collection.
Nix users and developers who work with Nix shells or flakes and want faster, more reliable direnv integration for their project environments.
Developers choose nix-direnv because it significantly speeds up environment loading after the first run, prevents accidental garbage collection of build dependencies, and works seamlessly as a drop-in replacement without requiring external daemons.
A fast, persistent use_nix/use_flake implementation for direnv [maintainer=@Mic92 / @bbenne10]
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Significantly speeds up subsequent shell loads by caching the evaluated Nix environment after the first run, reducing wait times as highlighted in the key features.
Prevents garbage collection of build dependencies by symlinking shell derivations to user gcroots, ensuring project caches persist even without internet access, a core feature mentioned in the README.
Includes a use_flake implementation that works with Nix flakes and protects flake inputs from garbage collection, enhancing flake-based workflows despite stability caveats.
Offers manual reload mode, devShell fallback disabling, and configurable tracked files, allowing users to customize environment loading behavior as described in the advanced usage section.
The README admits that flakes support is not guaranteed stable after Nix upgrades due to upstream API changes, which could lead to breakage in flake-based projects.
Requires Bash 4.4 or newer, which isn't default on systems like macOS (stuck on Bash 3.2), necessitating additional installation steps or workarounds, adding setup complexity.
Multiple installation methods exist, but some, like the recommended home-manager integration, make version control difficult, and setup varies across operating systems, requiring careful configuration.