Develop natively • Deploy containers • 100,000+ packages • Write scripts and tasks • 50+ languages • Define processes • Reuse services • Run tests • Enforce git hooks
Declaratively define your development environment by toggling basic options.
env
attribute set to define environment variables.
Include secrets from .env
file with
dotenv.enable = true;
.
enterShell
.
direnv
will
automatically load the environment when you enter the project directory.
{ pkgs, config, ... }: {
env.GREET = "determinism";
packages = [
pkgs.ncdu
];
enterShell = ''
echo hello ${config.env.GREET}
ncdu --version
'';
}
devenv shell hello determinism ncdu 2.3
{ pkgs, ... }: {
scripts.build = {
exec = "yarn build";
packages = [ pkgs.yarn ];
};
tasks."myapp:build" = {
exec = "build";
before = [ "devenv:enterShell" ];
};
# Runs on `git commit` and `devenv test`
git-hooks.hooks = {
black.enable = true;
# Your custom hooks
generate-css = {
enable = true;
name = "generate-css";
entry = "build";
};
};
}
devenv shell
...
Running tasks devenv:enterShell
Succeeded devenv:git-hooks:install 15ms
Succeeded myapp:build 23ms
Succeeded devenv:enterShell 23ms
3 Succeeded 50.14ms
$
Define scripts, tasks, and git hooks to automate your development workflow.
devenv search devenv
+--------------+---------------+------------------------------------------------------------------------+
| Package | Version | Description |
+--------------+---------------+------------------------------------------------------------------------+
| pkgs.devenv | 1.0.3 | Fast, Declarative, Reproducible, and Composable Developer Environments |
+--------------+---------------+------------------------------------------------------------------------+
+--------------------------+---------+-----------+------------------------------------------------------------+
| Option | Type | Default | Description |
+--------------------------+---------+-----------+------------------------------------------------------------+
| devenv.debug | boolean | false | Whether to enable debug mode of devenv enterShell script. |
+--------------------------+---------+-----------+------------------------------------------------------------+
| devenv.warnOnNewVersion | boolean | true | Whether to warn when a new version of devenv is available. |
+--------------------------+---------+-----------+------------------------------------------------------------+
| devenv.latestVersion | string | "1.0.3" | The latest version of devenv. |
+--------------------------+---------+-----------+------------------------------------------------------------+
• Found 1 package and 3 options for 'devenv'.
Supports over 50 programming languages.
{ pkgs, config, ... }: {
languages.python = {
enable = true;
version = "3.11";
venv.enable = true;
venv.requirements = ''
requests
torch
'';
uv.enable = true;
};
languages.rust = {
enable = true;
channel = "nightly";
rustflags = "-Z threads=8";
targets = [ "wasm32-unknown-unknown" ];
};
languages.php = {
enable = true;
version = "8.1";
ini = ''
memory_limit = 256M
'';
fpm.pools.web = {
settings = {
"pm" = "dynamic";
};
};
};
}
{ pkgs, ... }: {
packages = [
pkgs.cargo-watch
];
processes = {
cargo-watch.exec = "cargo watch -x run";
};
}
devenv up
• Building processes ...
• Starting processes ...
...
Define your
processes declaratively
and start them with
devenv up
.
Procfile
,
define development processes that have access
to your environment.
Choose from many community-maintained services like PostgreSQL, Redis, MySQL, RabbitMQ, WireMock, MinIO, Caddy, ElasticSearch, OpenTelemetry Collector, Prometheus, and more added regularly.
devenv up
.
{ pkgs, ... }: {
services.postgres = {
enable = true;
package = pkgs.postgresql_15;
initialDatabases = [{ name = "mydb"; }];
extensions = extensions: [
extensions.postgis
extensions.timescaledb
];
settings.shared_preload_libraries = "timescaledb";
initialScript = "CREATE EXTENSION IF NOT EXISTS timescaledb;";
};
}
devenv up
...
{ pkgs, ... }: {
packages = [
pkgs.mkdocs
pkgs.curl
];
processes = {
docs.exec = "mkdocs serve";
};
enterTest = ''
wait_for_port 8000
curl http://localhost:8000 | grep "Hello, world!"
'';
}
devenv test
...
Running scripts in your environment with all processes active
is as simple as devenv test
.
All process management is handled automatically, so you can focus on writing tests.
Generate containers from your development environment and build/copy/run them.
shell
container
lets you run your environment in a container.
Use devenv container run shell
to enter your environment in a container.
processes
container
lets you run your processes in a container.
Use devenv container run processes
to run your processes in a container.
containers.mycontainer.*
to
customize your container.
{ pkgs, ... }: {
packages = [
pkgs.mkdocs
pkgs.curl
];
processes = {
docs.exec = "mkdocs serve";
};
}
devenv container build processes ...
devenv container copy processes ...
devenv container run processes ...
inputs:
myorg-devenv:
url: github:myorg/myorg-devenv
imports:
- ./frontend
- ./backend
- myorg-devenv/service1
- myorg-devenv/service2
Compose multiple environments into a single environment.
Start with a central repository containing shared configuration until your team is comfortable maintaining their own environments.
Use the same interface for all languages for packaging applications. Define outputs to build your applications.
import
function to package your application using the best tools
for that ecosystem.
devenv build
to build your application outputs for distribution.
{ config, ... }: {
# https://devenv.sh/languages
languages = {
rust.enable = true;
python.enable = true;
};
# https://devenv.sh/outputs
outputs = {
rust-app = config.languages.rust.import ./rust-app {};
python-app = config.languages.python.import ./python-app {};
};
}