devenv: Fast, Declarative Dev Environments


devenv is a tool that builds fast, reproducible development environments using Nix. It focuses on declarative definitions, composable steps, and easy iteration across projects.

Quickstart — no fluff, just what you need

  • Initialize the environment
devenv init
  • Enter the development shell with relaxed hermeticity (useful when you need faster iteration and local experimentation)
devenv shell --impure
  • Inspect what telemetries and settings are currently active
devenv info --verbose
  • Run a project specific environment with a config file
devenv up --config path/to/file
  • Clean environment variables and re-enter in offline mode
devenv --clean --offline
  • Remove old shell generations to reclaim space
devenv gc

What is devenv good at

  • Declarative, reproducible environments powered by Nix
  • Composable steps so you can build your own workflow on top of core commands
  • Lightweight in your workflow while allowing heavy lifting from Nix where you need it

Core workflow patterns

  • Start fresh for a project
    • Run init to bootstrap the environment for the project
    • Enter shell when you want to modify code or run commands inside the dev container
    • Inspect with info to verify versions and active packages
    • Bring up services or tools with up using a config file tailored to the project
  • Offline or reproducible builds
    • Use the offline mode to avoid network access while still using cached results
    • Clean up environment variables to avoid leakage between runs
  • Cleanup and maintenance
    • Periodically run gc to clean old generations and reclaim space

Common pitfalls and how to avoid them

  • Hermeticity vs convenience
    • Relaxed hermeticity via —impure is great for fast iteration but can cause drift. Prefer a fully hermetic workflow for production budgets and CI.
  • Offline mode can surprise you
    • If you rely on remote fetches, offline mode might fail. Keep a local cache or disable offline when you know you need fresh dependencies.
  • Config drift across projects
    • Each project should have its own config; avoid reusing a single global config that assumes a stack of tools across projects.
  • Keeping environments in sync
    • Regularly run devenv info to verify the current environment is what you expect, especially after updates to tools or dependencies

Tips for productive use

  • Start with a minimal init and only add what you need to the config to keep devenv fast and readable
  • Use —config to pin exact versions and avoid drift between machines
  • Combine commands for repeated tasks, for example up and then gc after you finish a session if space is a concern
  • When debugging, use info —verbose to see what the environment contains and what paths are being used

Quick reference commands

  • Initialize
    • devenv init
  • Enter shell
    • devenv shell —impure
  • Show details
    • devenv info —verbose
  • Run with config
    • devenv up —config path/to/file
  • Offline cleanup
    • devenv —clean —offline
  • Cleanup generations
    • devenv gc

If you are curious for deeper details, the official getting started guide covers the full spectrum of commands and examples. Start with the basics, then gradually adopt more advanced features to fit your workflow.

See Also