Ad-hoc Developer Environments
Added in 1.6
Instead of creating and maintaining a devenv.nix file, you can create ad-hoc developer environments directly from the command line using the --option flag.
Basic Usage
Section titled “Basic Usage”You can specify any configuration option using the --option flag, allowing you to create temporary environments with specific tools and settings:
$ devenv --option languages.python.enable:bool true \ --option languages.python.version:string "3.10" \ shellThis creates a temporary Python development environment without needing any configuration files.
Option Types
Section titled “Option Types”The --option flag requires you to specify the inferred Nix type:
:stringfor string values:intfor integer values:floatfor floating-point values:boolfor boolean values (true/false):pathfor file paths (interpreted as relative paths):pkgfor a package:pkgsfor lists of packages (space-separated package names)
Installing Packages
Section titled “Installing Packages”To install packages from nixpkgs, use the special :pkgs type with the packages option:
$ devenv --option packages:pkgs "ncdu git ripgrep" shellThis creates an environment with ncdu, git, and ripgrep available, without needing a devenv.nix file.
Enabling Languages and Services
Section titled “Enabling Languages and Services”You can enable languages and services with ad-hoc environments:
$ devenv --option languages.rust.enable:bool true \ --option languages.rust.channel:string nightly \ shellRunning Ad-hoc Commands
Section titled “Running Ad-hoc Commands”You can also run specific commands directly in your ad-hoc environment:
$ devenv --option languages.elixir.enable:bool true shell iexThis example launches an Elixir interactive shell (iex) immediately after creating the environment.
Replacing vs. Appending Lists
Section titled “Replacing vs. Appending Lists”List types like :pkgs append to existing values by default. To replace the entire list instead, add a
! suffix to the type:
$ devenv -O packages:pkgs! "ncdu git" shellThis replaces all packages rather than appending to whatever devenv.nix already defines.
Combining with devenv.nix
Section titled “Combining with devenv.nix”When used with an existing devenv.nix file, --option values will override the configuration in the file.
Use Cases
Section titled “Use Cases”Ad-hoc environments are particularly useful for:
- One-off tasks that need specific dependencies
- Trying different configurations before committing to a
devenv.nixfile - Creating lightweight environments without project setup
- Creating a matrix of different options, e.g. testing different versions of Python
Limitations
Section titled “Limitations”While ad-hoc environments are convenient, they have some limitations:
- Complex configurations are better managed in a
devenv.nixfile - Some complex options may be harder to express on the command line

