Nix 101 Course / Section 3: Dev shells: the productivity unlock
Premium

3.6 direnv: dev shells that load themselves

Lesson 23 of 68 · 6:23

placeholder thumbnail

Sign in, then buy this course to watch

Free account · no credit card needed

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 direnv with nix profile and hooking it into your shell configuration
  • The one-line .envrc file you commit to the repo, in its flake and non-flake variants
  • Why direnv refuses 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.