devenv
Start Visual Studio Code in current directory
TLDR
Initialize the environment
Enter the Development Environment with relaxed hermeticity (state of being airtight)
Get detailed information about the current environment
Start processes with devenv
Clean the environment variables and re-enter the shell in offline mode
Delete the previous shell generations
SYNOPSIS
devenv [OPTIONS] <SUBCOMMAND> [ARGS]>
PARAMETERS
init [URL]
Initialize a new devenv.nix file, optionally from a template URL
shell
Enter a development shell with configured environment
up
Start managed processes and services (use devenv up -d for detached)
run SCRIPT
Execute a predefined script from devenv.nix
overlay
Enter a shell with Nix overlays applied
search [QUERY]
Search available package templates
-h, --help
Print help information
--version
Print version
--impure
Allow impure Nix builds
--flake URL
Use a specific flake URL instead of directory
DESCRIPTION
Devenv is a powerful CLI tool for creating reproducible, declarative development environments powered by Nix. It enables developers to define entire dev shells—including packages, services, environment variables, scripts, processes, and more—in a single devenv.nix file using Nix expressions.
Key features include:
• Shell activation: devenv shell drops you into a fully configured shell.
• Services management: devenv up starts background services like PostgreSQL, Redis, or custom processes.
• Direnv integration: Automatic environment loading in project directories.
• Polyglot support: Handles multiple languages, language servers, and tools seamlessly.
• Overlays and flakes: Leverages Nix flakes for pinning dependencies.
Ideal for teams seeking consistency across machines, it avoids global installations and supports quick onboarding. Unlike plain nix-shell, devenv excels at managing long-running services and complex setups. Install via Nix: nix profile install github:Astral-Software/Devenv. Usage starts with devenv init to bootstrap a project.
CAVEATS
Requires Nix >= 2.4 with flakes enabled; initial setup downloads can be large and slow on first use.
Services only run in project dir; not for production. Watch memory usage with many services.
DIRENV HOOK
Add use devenv to .envrc for auto-activation: devenv shell loads on cd.
EXAMPLE DEVENV.NIX
{ pkgs, ... }: { packages = [ pkgs.nodejs ]; scripts.hello.exec = ''echo hello''; } – Run with devenv run hello.
HISTORY
Developed by Astral (makers of Helix editor) starting 2022. v1.0 released 2023 with flake support. Evolved from community needs for better Nix dev tooling beyond nix-shell.


