devenv includes a built-in shell hook that automatically activates your developer environment when youDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/cachix/devenv/llms.txt
Use this file to discover all available pages before exploring further.
cd into a project directory. Unlike direnv-based setups, no external tools are required — just add a single line to your shell config and run one trust command per project.
Auto activation was introduced in devenv v2.1. Make sure you are on a recent version before following this guide.
Setup
Add the hook to your shell configuration file, then open a new terminal (or source the config file) for it to take effect.- Bash
- Zsh
- Fish
- Nushell
~/.bashrc
Trusting a Project
Before a project can auto-activate, you must explicitly trust it. This is a security measure that prevents untrusted projects from modifying your shell. Navigate to the project directory and run:cd into the directory, devenv activates automatically:
Revoking Trust
To stop a project from auto-activating:How It Works
The hook runs on every directory change and follows these steps:Check the trust database
Verifies that the discovered project directory was previously allowed via
devenv allow.The hook detects projects by looking for a
devenv.nix file. Before version 2.2, it looked for devenv.yaml instead, so projects with only devenv.nix were not auto-detected.Automatic Deactivation
When youcd out of the project directory (or any of its subdirectories), the devenv shell exits automatically and you return to your normal shell:
Re-entry Protection
The hook will not nest environments. While inside adevenv shell, navigating into a subdirectory of the same project keeps the current shell active. Only navigating outside the project root triggers deactivation.
Comparison with direnv
If you’re already using direnv, you may wonder which approach to choose. Here’s a quick comparison:| Feature | devenv hook | direnv |
|---|---|---|
| External dependencies | None | Requires direnv |
| Setup | One line in shell config | direnv install + .envrc per project |
| Trust granularity | Per project directory | Per .envrc file |
| Environment application | Spawns a subshell | Modifies current shell in place |
| Unloading on exit | Subshell exits automatically | direnv unloads variables |
