3.6 direnv: dev shells that load themselves
Lesson 23 of 68 · 6:23
Up next in 5s…
About this lesson
Typing nix-shell or nix develop in every project, every time, gets old fast. This lesson sets up direnv so the right development environment loads the moment you cd into a project folder and unloads when you leave. It works with flake and non-flake projects alike, and it reaches all the way into your editor.
In this video
- Installing
direnvwithnix profileand hooking it into your shell configuration - The one-line
.envrcfile you commit to the repo, in its flake and non-flake variants - Why
direnvrefuses to run anything until you approve it, and how that protects you from untrusted repositories - Watching tools appear on entering the folder and disappear on leaving it
- The VS Code extension that makes the editor pick up the environment too, so language servers and tools just work per project
After this lesson
You can check out any project in your organization, open it in your editor, and start working with the full toolchain loaded, without running a single setup command.