Skip to content

Devbox - Reproducible Dev Environments Cheatsheet

Devbox - Reproducible Dev Environments Cheatsheet

Devbox (by Jetify) creates isolated, reproducible development environments without Docker or virtual machines. It is powered by Nix but hides the Nix language behind a simple JSON config (devbox.json) and a familiar CLI — you run devbox add nodejs@20 instead of writing a Nix derivation. The result: everyone on the team (and CI) gets the exact same toolchain, pinned to precise versions, isolated from the host system.

Installation

MethodCommand
Install script`curl -fsSL https://get.jetify.com/devbox
RequirementNix (Devbox can install it for you)
Verifydevbox version

Getting Started

CommandDescription
devbox initCreate a devbox.json in the project
devbox add nodejs@20 python@3.12Add packages (pinned versions)
devbox rm pythonRemove a package
devbox installInstall everything in devbox.json
devbox shellEnter the isolated environment
devbox run <script>Run a defined script inside the env

Managing Packages

CommandDescription
devbox add go@1.22Add a specific version
devbox search postgresqlSearch the Nix package catalog
devbox listList installed packages
devbox updateUpdate packages to latest allowed
devbox info nodejsShow details for a package

Versions resolve against the Nixpkgs catalog, so nodejs@20 is reproducible everywhere.

The Config (devbox.json)

{
  "packages": ["nodejs@20", "python@3.12", "postgresql@16"],
  "shell": {
    "init_hook": ["echo 'Welcome to the project env'"],
    "scripts": {
      "dev": "npm run dev",
      "test": "npm test",
      "db": "pg_ctl start"
    }
  }
}
FieldPurpose
packagesPinned tool/language versions
shell.init_hookCommands run on entering the shell
shell.scriptsNamed commands (devbox run dev)
envEnvironment variables for the project

Shell & Scripts

CommandDescription
devbox shellInteractive isolated shell
devbox run devRun the dev script
devbox run -- npm ciRun an arbitrary command in the env
exitLeave the Devbox shell

Services (Process Management)

Devbox can manage background services (databases, etc.) for a project.

CommandDescription
devbox services lsList configured services
devbox services upStart services
devbox services stopStop services
devbox add postgresql --start-servicesAdd a service-backed package

CI & Containers

UseHow
CIInstall Devbox, run devbox run test — identical env to local
Dockerdevbox generate dockerfile produces a reproducible image
Devcontainerdevbox generate devcontainer for VS Code
Direnvdevbox generate direnv to auto-enter the env on cd

Common Workflows

# Stand up a reproducible project env from scratch
devbox init
devbox add nodejs@20 postgresql@16
devbox shell           # now node + postgres are available, pinned

# Run tasks the same way locally and in CI
devbox run test

# Produce a Docker image from the same definition
devbox generate dockerfile

Devbox vs Alternatives

AspectDevboxDev ContainersNix (raw)mise
BackendNixDockerNixOwn registry
ConfigJSONdevcontainer.jsonNix language.mise.toml
IsolationReal (Nix store)ContainerRealTool versions
Learning curveGentleModerateSteepGentle
Best forReproducible envs, easyContainer-based devFull Nix powerVersion management

See also Nix for the underlying power, devcontainer for container-based dev, and mise for tool-version management.

Resources