devenv 1.6: Extensible Ad-Hoc Nix Environments
devenv 1.6 has been tagged, allowing you to:
- Create temporary environments directly from the command line without requiring a
devenv.nixfile. - Temporarily modify existing environments.
Create Environments on the Fly
Section titled “Create Environments on the Fly”Developer environments on demand using the new --option (-O) flag:
$ devenv --option languages.python.enable:bool true \ --option packages:pkgs "ncdu git ripgrep" \ shellThis command creates a temporary Python environment without writing any configuration files.
Ad-hoc environments are ideal for quickly testing languages or tools without committing to a full project setup:
$ devenv -O languages.elixir.enable:bool true shell iexSupported Option Types
Section titled “Supported Option Types”The --option flag supports multiple data types, making it flexible for various use cases:
:stringfor text values:intfor integers:floatfor decimal numbers:boolfor true/false values:pathfor file paths:pkgsfor specifying Nix packages
GitHub Actions with Matrices
Section titled “GitHub Actions with Matrices”One of the most powerful applications of ad-hoc environments is in CI pipelines, where you can easily implement testing matrices across different configurations:
jobs: test: strategy: matrix: python-version: ['3.9', '3.10', '3.11'] steps: - uses: actions/checkout@v3 - uses: cachix/install-nix-action@v31 - uses: cachix/cachix-action@v16 with: name: devenv - name: Install devenv.sh run: nix profile install nixpkgs#devenv - name: Test with Python {{ '${{ matrix.python-version }}' }} run: | devenv --option languages.python.enable:bool true \ --option languages.python.version:string {{ '${{ matrix.python-version }}' }} \ testThis approach lets you validate your code across multiple language versions or dependency combinations without maintaining separate configuration files for each scenario.
Combining with Existing Configurations
Section titled “Combining with Existing Configurations”When used with an existing devenv.nix file, --option values override the configuration settings in the file, making it easy to temporarily modify your environment.
Switching Between Environment Profiles
Section titled “Switching Between Environment Profiles”Ad-hoc options are perfect for switching between predefined profiles in your development environment:
$ devenv --option profile:string backend upThis enables you to switch between frontend, backend, or other custom profiles without modifying your configuration files.
See our Profiles guide for more details on setting up and using profiles.
For complete documentation on this feature, visit our Ad-hoc Developer Environments guide.
We’re excited to see how you’ll use ad-hoc environments to streamline your development workflow. Share your feedback on GitHub or join our Discord community!

