Develop natively • Deploy containers • 100.000+ packages • Write scripts and tasks • 50+ supported languages • Define processes • Reuse services • Run tests • Enforce git hooks
Simple JSON-like language
Declaratively define your development environment by toggling basic options.
env
attribute set to define environment variables.
If you'd like to also include secrets from
.env
file, set
dotenv.enable = true;.
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, ... }: {
packages = [ pkgs.yarn ];
scripts.build.exec = "yarn build";
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
$
Scripts and Tasks
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'.
Languages
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 ...
...
Run processes
Define your
processes in a declarative way
and start them with
devenv up.
Procfile,
declare development processes that have access
to your environment.
Run services
Pick from a number of community maintained services like PostgreSQL, Redis, MySQL, RabbitMQ, WireMock, MinIO, Caddy, ElasticSearch, OpenTelemetry Collector, Prometheus, and more are being added each day.
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
...
Run tests
Running
a script inside your development environment with
all processes running
should be as simple as
devenv test.
All process management is taken care for you.
Container interoperability
Generate containers from your development environment and build/copy/run them.
shell
container allows you to run your environment in
a container.
Use
devenv container run shell
to enter your environment in a container.
processes
container allows you to 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
Poly/Mono repo composability
Compose multiple environments into a single environment.
A great way to get started is to use central repository with all the shared configuration until your team is comfortable maintaining their own environments.