Every devenv project is configured through aDocumentation 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.
devenv.nix file. This file is written in the Nix expression language and describes your complete developer environment — packages, environment variables, shell hooks, and more — in a single declarative source of truth that works identically on every machine.
The devenv.nix File Structure
devenv.nix is a Nix function that accepts inputs and returns an attribute set (think of it as a typed key-value object, similar to a JSON object). Here is a minimal annotated example:
{ pkgs, ... }:— The file is a function.pkgsis a special input that gives you access to the entire Nixpkgs package collection. The...catch-all means you don’t have to enumerate every possible input.{ ... }— The function returns an attribute set. This is the environment definition.env.GREET = "hello";— Attributes can be nested.env.*keys become shell environment variables. Values can be strings, numbers, booleans, lists, or references to other inputs.enterShell = ''...''— Values can reference inputs such aspkgs. See Inputs for how to define custom inputs.
New to Nix? The Nix language tutorial is a 1–2 hour deep dive that will allow you to read any Nix file confidently.
Entering the Shell
Rundevenv shell to build and activate the environment defined in devenv.nix. The enterShell script runs automatically on activation:
(devenv) prefix in the prompt indicates you are inside the managed environment. Every package listed in packages is available on $PATH, and every env.* variable is exported.
Environment Variables
Declare environment variables under theenv attribute. Any key you set here is exported into the shell and visible to all scripts, processes, and tools running inside the environment:
enterShell, tasks, processes, and tests.
Adding Packages
Add packages from Nixpkgs via thepackages list. Use pkgs.<name> to reference any of the 100,000+ packages available:
The enterShell Hook
enterShell runs a bash script every time you enter the environment with devenv shell. It is the right place for lightweight setup steps such as printing a welcome message or running a quick version check:
Viewing the Environment Summary
Rundevenv info at any time to print a structured summary of the active environment — useful for verifying that variables, packages, and scripts are configured correctly:
Putting It All Together
Here is the fulldevenv.nix generated by devenv init, which demonstrates the most common configuration options side by side:
