22 November 2026 · NixOSaaS
What Is devenv.sh? A Beginner’s Guide to Development Environments
Understand Nix, NixOS and devenv, then try one small Python environment—with every configuration line explained.
You download a project, open its folder and try to run it. The instructions say you need Python, a few libraries and a particular version of another tool. Your laptop already has some of them—but are they the right versions?
This setup work is part of creating a development environment: the tools, dependencies and settings you use to write, run and test software.
devenv helps you describe that environment in files stored beside your application. You can then enter the environment and use its tools without manually rebuilding the setup from a checklist each time.
What does the name mean?
devenv.sh is the project’s website. The command you type in a terminal is devenv; you do not run a script called devenv.sh.
Think of a project as a recipe with a list of required equipment. Your application files contain the recipe. The development environment describes the equipment needed to work on it.
For one project that might mean Python and a formatter. Another might need Go, PostgreSQL and commands for running tests.
How do Nix, NixOS and devenv relate?
| Name | Role |
|---|---|
| Nix | Provides package management and tools for constructing declared environments. |
| NixOS | A Linux distribution that also uses Nix to configure the operating system. |
| devenv | Builds on Nix to make project environments, tasks and development services convenient to configure. |
You do not need to replace your operating system with NixOS. You can use Nix and devenv on supported Linux and macOS systems. NixOS already includes Nix.
The configuration uses the Nix language. You only need a little syntax to start; our Introduction to the Nix programming language explains the building blocks more slowly.
What can it manage?
A project can declare language tools, command-line utilities, environment variables, repeatable tasks and supporting services such as databases. You can start small and add these as needed.
This does not make existing tools obsolete. Python virtual environments and npm still have useful roles in managing application libraries. Containers remain useful when you need their runtime and network separation. devenv helps bring the project’s development setup together.
Try one tiny Python environment
First install Nix and devenv using the official installation guide. For Nix installation help, our earlier guides cover Linux and macOS.
In a fresh Bash or Zsh terminal, check:
nix --version
devenv --version
Both should print a version. If either says command not found, finish its installation before continuing. You do not need a separate Python installation for this exercise.
Create a new folder:
mkdir -p ~/devenv-first-project
cd ~/devenv-first-project
devenv init
Open the generated devenv.nix in your text editor. Replace its contents with:
{ pkgs, ... }:
{
packages = [ pkgs.python3 ];
env.PROJECT_NAME = "My first devenv project";
}
| Line | What it means |
|---|---|
{ pkgs, ... }: | Accept the package collection supplied by devenv; ... permits other supplied arguments. |
| Opening and closing braces | Group the environment’s settings. |
packages = [ pkgs.python3 ]; | Make the package collection’s default Python 3 available. Square brackets hold a list. |
env.PROJECT_NAME = "..."; | Set a named text value that programs in the environment can read. |
The semicolons finish assignments. python3 selects the default Python 3 from the chosen package collection; it does not request a particular minor release.
Enter your environment:
devenv shell
The first run may download packages or build missing ones. Wait until the shell prompt returns, then run:
python --version
command -v python
python -c 'import os; print("Hello from", os.environ["PROJECT_NAME"])'
The first command reports Python’s version. The second shows which executable the shell selected. The last runs a short Python program that reads our setting. Its expected output is:
Hello from My first devenv project
Leave this shell with:
exit
You return to your previous environment. If it already had Python, that installation remains available. Downloaded Nix packages remain on disk for reuse.
This teaching example follows the documented package and environment-variable configuration. It has not been executed end to end for this article.
Which files should you keep?
| File | Purpose |
|---|---|
devenv.nix | Declares tools and settings. |
devenv.yaml | Configures input sources. |
devenv.lock | Records resolved input revisions for repeatability. |
Keep these files in version control with your application. A shared lock helps colleagues resolve the same package definitions. Application dependencies may need separate locks, such as package-lock.json or uv.lock.
What does “isolated” mean here?
A development shell selects project tools and settings. It is not automatically a security sandbox: commands still have your user’s filesystem and network access. Host settings can influence behaviour, and services can conflict over ports.
Also, changing folders alone does not switch an existing shell’s environment. Start with explicit devenv shell and exit; automatic activation can come later.
Continue learning
Continue with One Laptop, Multiple Projects: Reproducible Development with Nix and devenv.sh to practise using different Python and Node.js versions on the same machine.
For the underlying tools, revisit our Nix language introduction. Official references: devenv basics and pinning inputs.