Devenv
Fast, Declarative, Reproducible, and Composable Developer Environments using Nix
Install / Use
/learn @cachix/DevenvREADME
<p align="center">
<a href="https://devenv.sh">
<picture>
<source media="(prefers-color-scheme: light)" srcset="logos/devenv-horizontal-light-bg.svg">
<source media="(prefers-color-scheme: dark)" srcset="logos/devenv-horizontal-dark-bg.svg">
<img src="logos/devenv-horizontal-light-bg.svg" width="500px" alt="devenv logo">
</picture>
</a>
</p>
devenv.sh - Fast, Declarative, Reproducible, and Composable Developer Environments
Features
Developer experience
- Terminal UI with live build progress, task hierarchy, and error details
- Native shell reloading that rebuilds in the background while your shell stays interactive
- Instant environments with incremental Nix evaluation caching (sub 100ms when nothing changed)
- LSP for devenv.nix with autocomplete, hover docs, and go to definition via bundled nixd
- Ad hoc environments from the CLI without any config files (
--option languages.rust.enable:bool true) - Out of tree devenvs to use configs from other repos (
--from github:myorg/configs)
Languages, packages, and services
- 50+ languages with built in tooling: compilers, LSP servers, formatters, linters, and version selection
- 100,000+ packages from Nixpkgs for Linux, macOS, x64, and ARM64 (including WSL2)
- 40+ services like PostgreSQL, Redis, MySQL, MongoDB, Elasticsearch, Caddy, and more
Processes and tasks
- Native process manager written in Rust with dependency ordering, restart policies, readiness probes (exec, HTTP, systemd notify), socket activation, watchdog heartbeats, and file watching
- Automatic port allocation that finds free ports so parallel environments never collide
- Tasks with DAG based execution, caching, parallel runs, and namespace support
- Scripts with access to all environment packages
Packaging and deployment
- OCI containers built from your environment without Docker
- Outputs for packaging apps using each language's best tools (crate2nix, uv2nix, ...)
- Polyrepo support to reference outputs and options across repositories
Composition and configuration
- Profiles for environment variants (
--profile backend --profile testing) - Composable via imports to share and reuse environments across projects
- Inputs for pinning and overriding Nix dependencies
Security and integrations
- SecretSpec for declarative, provider agnostic secrets management (keyring, 1Password, dotenv)
- Git hooks via git-hooks.nix with pre configured formatters and linters
- Testing with
devenv testthat automatically starts and stops processes - direnv integration for automatic shell activation when entering a directory
- MCP server for AI assistant integration (package and option search)
- AI generation to scaffold environments from a natural language description
Quick start
Running devenv init generates devenv.nix:
{ pkgs, lib, config, inputs, ... }:
{
# https://devenv.sh/basics/
env.GREET = "devenv";
# https://devenv.sh/packages/
packages = [ pkgs.git ];
# https://devenv.sh/languages/
# languages.rust.enable = true;
# https://devenv.sh/processes/
# processes.dev.exec = "${lib.getExe pkgs.watchexec} -n -- ls -la";
# https://devenv.sh/services/
# services.postgres.enable = true;
# https://devenv.sh/scripts/
scripts.hello.exec = ''
echo hello from $GREET
'';
# https://devenv.sh/basics/
enterShell = ''
hello # Run scripts directly
git --version # Use packages
'';
# https://devenv.sh/tasks/
# tasks = {
# "myproj:setup".exec = "mytool build";
# "devenv:enterShell".after = [ "myproj:setup" ];
# };
# https://devenv.sh/tests/
enterTest = ''
echo "Running tests"
git --version | grep --color=auto "${pkgs.git.version}"
'';
# https://devenv.sh/outputs/
# outputs = {
# rust-app = config.languages.rust.import ./rust-app {};
# python-app = config.languages.python.import ./python-app {};
# };
# https://devenv.sh/git-hooks/
# git-hooks.hooks.shellcheck.enable = true;
# See full reference at https://devenv.sh/reference/options/
}
And devenv shell activates the environment.
Commands
$ devenv
https://devenv.sh 2.0.0: Fast, Declarative, Reproducible, and Composable Developer Environments
Usage: devenv [OPTIONS] [COMMAND]
Commands:
init Scaffold devenv.yaml, devenv.nix, and .gitignore.
generate Generate devenv.yaml and devenv.nix using AI
shell Activate the developer environment. https://devenv.sh/basics/
update Update devenv.lock from devenv.yaml inputs. http://devenv.sh/inputs/
search Search for packages and options in nixpkgs. https://devenv.sh/packages/#searching-for-a-file
info Print information about this developer environment.
up Start processes in the foreground. https://devenv.sh/processes/
processes Start or stop processes. https://devenv.sh/processes/
tasks Run tasks. https://devenv.sh/tasks/
test Run tests. http://devenv.sh/tests/
container Build, copy, or run a container. https://devenv.sh/containers/
inputs Add an input to devenv.yaml. https://devenv.sh/inputs/
changelogs Show relevant changelogs.
repl Launch an interactive environment for inspecting the devenv configuration.
gc Delete previous shell generations. See https://devenv.sh/garbage-collection
build Build any attribute in devenv.nix.
eval Evaluate any attribute in devenv.nix and return JSON.
direnvrc Print a direnvrc that adds devenv support to direnv. See https://devenv.sh/integrations/direnv/.
version Print the version of devenv.
mcp Launch Model Context Protocol server for AI assistants
lsp Start the nixd language server for devenv.nix.
help Print this message or the help of the given subcommand(s)
Input overrides:
--from <FROM>
Source for devenv.nix.
Can be either a filesystem path (with path: prefix) or a flake input reference.
Examples:
--from github:cachix/devenv
--from github:cachix/devenv?dir=examples/simple
--from path:/absolute/path/to/project
--from path:./relative/path
-o, --override-input <NAME> <URI>
Override inputs in devenv.yaml.
Examples:
--override-input nixpkgs github:NixOS/nixpkgs/nixos-unstable
--override-input nixpkgs path:/path/to/local/nixpkgs
-O, --option <OPTION:TYPE> <VALUE>
Override configuration options with typed values.
OPTION must include a type: <attribute>:<type>
Supported types: string, int, float, bool, path, pkg, pkgs
List types (pkgs) append to existing values by default.
Add a ! suffix to replace instead: pkgs!
Examples:
--option languages.rust.channel:string beta
--option services.postgres.enable:bool true
--option languages.python.version:string 3.10
--option packages:pkgs "ncdu git" (appends to packages)
--option packages:pkgs! "ncdu git" (replaces all packages)
Nix options:
-j, --max-jobs <MAX_JOBS>
Maximum number of Nix builds to run concurrently.
Defaults to 1/4 of available CPU cores (minimum 1).
[env: DEVENV_MAX_JOBS=]
-u, --cores <CORES>
Number of CPU cores available to each build.
Defaults to available cores divided by max-jobs (minimum 1).
[env: DEVENV_CORES=]
-s, --system <SYSTEM>
Override the target system.
Defaults to the host system (e.g. aarch64-darwin, x86_64-linux).
-i, --impure
Relax the hermeticity of the environment.
--no-impure
Force a hermetic environment, overriding config.
--offline
Disable substituters and consider all previously downloaded files up-to-date.
