Instead of creating and maintaining aDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/cachix/devenv/llms.txt
Use this file to discover all available pages before exploring further.
devenv.nix file, you can create ad-hoc developer environments directly from the command line using the --option flag. This is ideal for quick experiments, one-off tasks, or testing a tool before committing to a full project configuration.
Basic Usage
Pass any devenv configuration option with--option, specifying the inferred Nix type as a suffix. For example, to spin up a Python 3.10 shell without any config file:
Option Types
Every--option value requires a type annotation after the option name:
| Suffix | Type | Example value |
|---|---|---|
:string | String | "3.10" |
:int | Integer | 8080 |
:float | Float | 3.14 |
:bool | Boolean | true / false |
:path | File path (relative) | ./mydir |
:pkg | Single nixpkgs package | ripgrep |
:pkgs | Space-separated list of packages | "ncdu git ripgrep" |
Installing Packages
Use the special:pkgs type with the packages option to install tools from nixpkgs on the fly:
ncdu, git, and ripgrep available — no devenv.nix required.
Enabling Language Toolchains
Enable any language module and configure it inline. The following example activates the Rust toolchain on the nightly channel:Running Ad-hoc Commands
You can run a specific command inside the ad-hoc environment by passing it aftershell:
iex) immediately after the environment is ready — no separate devenv shell step needed.
Replacing vs. Appending Lists
List types like:pkgs append to existing values by default. Use a ! suffix on the type to replace the entire list instead:
devenv.nix and replaces the list with only ncdu and git.
Using a Remote Configuration with --from
The --from flag lets you use a devenv.nix stored in another location — a remote GitHub repository or a local path — without needing any config files in the current directory:
--from accepts any Nix flake input reference. It works with devenv shell, devenv test, and devenv build. Currently --from only supports projects that use devenv.nix alone; projects that also rely on devenv.yaml for extra inputs are not yet supported.
Combining with an Existing devenv.nix
When run inside a project that already has a devenv.nix, values passed via --option override the matching settings in the file. The rest of the configuration is inherited unchanged, making it easy to test variations without editing the file.
Use Cases
Ad-hoc environments shine in situations such as:Quick tool trials
Quick tool trials
Test a language or tool before adding it to your project’s
devenv.nix. For example, try out a newer Python version with a single command before committing.One-off scripting tasks
One-off scripting tasks
Run a utility that isn’t part of your normal environment —
ncdu to analyse disk usage, jq to process JSON — without permanently changing the project config.Matrix testing
Matrix testing
Combine with shell scripting to iterate over a set of options, for example testing the same code against multiple Python versions:
Limitations
Ad-hoc environments are best for simple configurations. For complex setups — multiple services, custom scripts, Git hooks — a
devenv.nix file provides better readability and reproducibility. Some deeply nested options may also be harder to express on the command line.