devenv
npx machina-cli add skill kissgyorgy/coding-agents/devenv --openclawdevenv.sh Development Environments
Create fast, declarative, reproducible development environments using devenv.sh powered by Nix. Official docs: https://devenv.sh
For setting up specific programming languages, services, package managers, see:
- python-uv.md - Detailed Python/uv configuration
- services.md - Complete services configuration guide
- django.md - Django project setup and patterns
Initialize a New Environment
devenv init
This creates:
devenv.yaml- Input configurationdevenv.nix- Environment definition (where you configure everything).envrc- direnv integration.gitignore- Ignores devenv artifacts
Remove comments from .gitignore after init.
Edit devenv.yaml and replace the inputs section:
inputs:
nixpkgs:
url: github:NixOS/nixpkgs/nixpkgs-unstable
This gives access to the latest packages from nixpkgs.
Adding Nix Packages
Add system packages to your environment:
{ pkgs, ... }: {
packages = with pkgs; [
just # always add this
postgresql # For psql CLI
redis # For redis-cli
];
}
Search for packages:
devenv search <package-name>
Only works after devenv init
Update Lock File
After changing inputs:
devenv update
This updates devenv.lock with pinned versions.
IMPORTANT: ALWAYS run devenv build after editing devenv.nix to make sure the configuration is working.
Fix any problems that occurs during build.
Environment Variables
{
env = {
MY_VAR = "value";
PYTHONUNBUFFERED = "1";
};
}
Common Commands
devenv init- Initialize new environmentdevenv shell- Enter development shelldevenv up- Start services and processes (foreground)devenv up -d- Start services in backgrounddevenv processes stop- Stop all processesdevenv test- Run testsdevenv update- Update dependencies from devenv.yamldevenv search <pkg>- Search for packagesdevenv info- Show environment info
File Structure
Key files devenv manages:
devenv.nix- Your environment configuration (commit this)devenv.yaml- Input sources (commit this)devenv.lock- Pinned versions (commit this).envrc- direnv integration (commit this).devenv/- Build artifacts (don't commit)
Complete Example
{ pkgs, ... }: {
# Python with uv
languages.python = {
enable = true;
version = "3.12";
uv = {
enable = true;
sync.enable = true;
};
libraries = with pkgs; [ postgresql stdenv.cc.cc.lib ];
};
# Services
services = {
postgres = {
enable = true;
package = pkgs.postgresql_15;
initialDatabases = [{ name = "app"; }];
};
redis.enable = true;
};
# Packages
packages = with pkgs; [
git
postgresql
redis
];
# Environment
env = {
DATABASE_URL = "postgresql://localhost/app";
REDIS_URL = "redis://localhost:6379";
};
# Processes
processes = {
web = {
exec = "python manage.py runserver 0.0.0.0:8000";
process-compose.depends_on = {
postgres.condition = "process_healthy";
redis.condition = "process_healthy";
};
};
worker = {
exec = "celery -A myapp worker";
process-compose.depends_on = {
redis.condition = "process_healthy";
};
};
};
# Scripts
scripts = {
migrate = {
exec = "python manage.py migrate";
description = "Run migrations";
};
test = {
exec = "pytest";
description = "Run tests";
};
};
# Enable dotenv
dotenv.enable = true;
}
Troubleshooting
Issue: Package not found
Search for it:
devenv search <package>
Ensure using nixpkgs-unstable in devenv.yaml.
Issue: Python package won't install
Add native dependencies to languages.python.libraries:
{
languages.python.libraries = with pkgs; [
postgresql # For psycopg2
stdenv.cc.cc.lib
];
}
Source
git clone https://github.com/kissgyorgy/coding-agents/blob/master/skills/devenv/SKILL.mdView on GitHub Overview
devenv.sh creates fast, declarative, reproducible development environments powered by Nix. It lets you define languages, services, and dependencies in devenv.yaml and devenv.nix, with direnv integration via .envrc. This keeps your project setup consistent across machines and teams.
How This Skill Works
Start with devenv init to generate configuration files (devenv.yaml, devenv.nix, .envrc, .gitignore). Then customize inputs, packages, and services, and use devenv build to validate the configuration. Finally, use devenv up or devenv shell to run services and enter the development environment, all backed by a pinned nixpkgs lockfile.
When to Use It
- Need a fast, reproducible dev environment across machines.
- Want to declare languages, services, and package managers in one place.
- Need to pin package versions and update them with a lockfile.
- Want to start, stop, or monitor services and processes easily.
- Need to quickly search for packages and validate installation with devenv build.
Quick Start
- Step 1: devenv init
- Step 2: Edit devenv.yaml to configure inputs, packages, and services
- Step 3: devenv build and then devenv up to start services
Best Practices
- Commit devenv.yaml, devenv.nix, and devenv.lock to version control.
- Run devenv build after editing devenv.nix to catch configuration errors early.
- Keep inputs updated and use devenv update to refresh the lock file.
- Enable dotenv and direnv (dotenv.enable = true) and commit .envrc.
- Follow the complete example patterns (languages, services, processes) to organize complex projects.
Example Use Cases
- Python project with uv support and a Postgres/Redis service stack.
- Django app configured with runserver, migrations, and environment variables.
- Celery worker defined as a separate process with dependencies on Redis.
- Environment variables like DATABASE_URL and REDIS_URL defined in the env block.
- Scripts to migrate databases or run tests via devenv scripts block.