Nix Flakes provide a standardised way to manage Nix projects — pinning dependencies in a lock file and producing structured outputs. devenv can be consumed as a flake module so that its full language/process/service module system becomes available inside an existingDocumentation 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.
flake.nix, or via flake-parts for a more modular multi-system configuration.
If you are new to devenv and Nix, starting with the standard
devenv.nix + devenv.yaml approach will give you the smoothest experience. The flake integration is aimed at experienced Nix users with an existing flake-based ecosystem.When to Use Flakes vs the devenv CLI
For most projects we recommend using the dedicated devenv CLI. However, the flake integration makes sense when:- You already maintain a flake-based project ecosystem.
- Your dev shell needs to be consumed as a
devShelloutput by downstream flakes. - You are an experienced Nix user comfortable with flake evaluation semantics.
Feature Comparison
| Feature | devenv CLI | Nix Flakes |
|---|---|---|
| External flake inputs | ✅ | ✅ |
| Shared remote configs | ✅ | ✅ |
| Designed for developer environments | ✅ | ❌ |
| Built-in container support | ✅ | ❌ |
| Protection from garbage collection | ✅ | ❌ |
| Faster evaluation (lazy trees) | ✅ | ❌ |
| Evaluation caching | ✅ | ❌ |
| Pure evaluation | ✅ | ❌ (impure by default) |
| Cross-project references | ✅ | ✅ |
| secretspec.dev | ✅ | ❌ |
| Running processes when testing | ✅ | ❌ |
Option A: Plain Nix Flakes
Initialise from the Template
flake.nix with a basic devenv configuration and an optional .envrc for direnv support.
Minimal flake.nix
The shell is defined as a devShell output built with devenv.lib.mkShell:
Entering the Shell
Flakes use pure evaluation by default, which prevents devenv from querying the working directory. The
--no-pure-eval flag relaxes this restriction. Alternatively, you can override devenv.root to an absolute path, but that makes the flake non-portable.Launching Processes and Running Tests
Once inside the shell, use the standard devenv commands:Multiple Shells in One Flake
For monorepos or projects with multiple components, define severaldevShells:
External Flakes
If you cannot add aflake.nix to the project repository, create a central flake in a separate repo and reference it:
github: and git: URLs. See Nix flake references for the full syntax.
Automated Shell Switching with direnv
Install nix-direnv
Follow the nix-direnv installation guide.
devenv up, devenv test, and devenv tasks skip re-evaluation and use the cached environment, starting significantly faster.
Option B: flake-parts
flake-parts provides a modular framework for organising flakes across multiple systems. devenv ships aflakeModule you can import directly.
Initialise from the Template
Minimal flake.nix with flake-parts
systems. The devenv configuration lives under devenv.shells.<name> inside perSystem.
