Skip to main content

Documentation 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 manages several files in your project directory and exposes a set of built-in environment variables that let your scripts and processes refer to well-known paths. Understanding these files and variables is key to structuring a devenv project effectively.

Project files

The only required file for specifying the developer environment. Generated by devenv init and thoroughly documented — see the basics to get started.
Same as devenv.nix, but not meant to be committed to the Git repository. Developers can use it to override settings for their local setup without affecting the shared environment.
Configuration for inputs and imports, allowing you to specify dependencies and how to compose them.You can require a specific devenv version to make sure all developers use a compatible version:
devenv.yaml
# Enforce CLI matches the modules version
require_version: true

# Or use an explicit constraint
require_version: ">=2.1"
See the devenv.yaml reference for details.
New in devenv 1.10. Same as devenv.yaml, but not meant to be committed to the Git repository. Useful for local overrides to inputs or imports.
Pinned inputs that ensure your developer environment is reproducible. Updated automatically by devenv when inputs change.
direnv integration logic. See the direnv integration guide to set up your shell to automatically activate the developer environment when you cd into the project directory.

Environment variables

Setting variables in devenv.nix

Use the env option to declare environment variables that are available in your shell and all processes:
devenv.nix
{ pkgs, config, ... }:

{
  env.GREET = "hello";

  enterShell = ''
    echo ${config.env.GREET}
  '';
}

Built-in devenv variables

devenv injects these variables automatically whenever your environment is active:

$DEVENV_ROOT

Points to the root of the project where devenv.nix is located.

$DEVENV_DOTFILE

Points to $DEVENV_ROOT/.devenv.

$DEVENV_STATE

Points to $DEVENV_DOTFILE/state. Use this for service data directories and other state that should persist across shell sessions.

$DEVENV_RUNTIME

Points to a temporary directory unique to each $DEVENV_ROOT. Used for sockets and other runtime files. Defaults to $XDG_RUNTIME_DIR, falling back to $TMPDIR and finally /tmp.

$DEVENV_PROFILE

Points to the Nix store path containing the final profile of packages and scripts provided by devenv. Useful for teaching other programs about /bin, /etc, and /var folders.

$DEVENV_HOME

Points to ~/.local/share/devenv (following the XDG data directory convention). Stores GC roots and other persistent per-user data.

Build docs developers (and LLMs) love