Skip to main content

Documentation 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 gives you access to over 100,000 packages from Nixpkgs — the world’s largest software repository. Packages are declared once in devenv.nix and automatically added to every developer’s PATH when they enter the shell. No installation scripts, no version drift, no “works on my machine.”

Declaring Packages

Add packages using the packages option, referencing them from the pkgs argument:
devenv.nix
{ pkgs, ... }:

{
  packages = [
    # Executables
    pkgs.git
    pkgs.jq
    # Libraries
    pkgs.libffi
    pkgs.zlib
  ];
}
Packages are added to PATH — and libraries to the relevant search paths — as soon as you enter the shell:
$ jq
jq: command not found

$ devenv shell
Building shell ...
Entering shell ...

(devenv) $ jq --version
jq-1.6

Searching for Packages

Use devenv search <NAME> to find available packages. Results are scoped to the exact version of Nixpkgs pinned in your devenv.lock:
$ devenv search ncdu
name         version  description
----         -------  -----------
pkgs.ncdu    2.2.1    Disk usage analyzer with an ncurses interface
pkgs.ncdu_1  1.17     Disk usage analyzer with an ncurses interface
pkgs.ncdu_2  2.2.1    Disk usage analyzer with an ncurses interface


No options found for 'ncdu'.

Found 3 packages and 0 options for 'ncdu'.
You can also browse packages online at search.nixos.org. The results there correspond to the unstable channel, but the names are the same as what you use in devenv.nix.

Searching for a File

If you know a file name — for example a shared library like libquadmath.so — but not which package provides it, you can use the nix-index-database:
$ nix run github:nix-community/nix-index-database libquadmath.so
(rPackages.RcppEigen.out)                       302,984 x /nix/store/24r9jkqyf2nd5dlg1jyihfl82sa9nwwb-gfortran-12.3.0-lib/lib/libquadmath.so.0.0.0
(zsnes2.out)                                    693,200 x /nix/store/z23qmfjaj5p50n3iki7zkjjgjzia16v1-gcc-12.3.0-lib/lib/libquadmath.so.0.0.0
...

Using Packages in Scripts and enterShell

Packages declared in packages are available everywhere inside the environment — including enterShell hooks and scripts. You can reference them either by name (since they are on PATH) or by their Nix store path for precise pinning:
{ pkgs, ... }:

{
  packages = [ pkgs.curl pkgs.jq ];

  enterShell = ''
    echo "curl version: $(curl --version | head -1)"
  '';
}

Pinning a Specific Package Version

By default, all packages come from the Nixpkgs revision pinned in your devenv.lock. If you need a newer or older version of a specific package, you can fetch it from a separate Nixpkgs input.
1

Add a second Nixpkgs input to devenv.yaml

devenv.yaml
inputs:
  nixpkgs:
    url: github:NixOS/nixpkgs/nixpkgs-unstable
  nixpkgs-stable:
    url: github:NixOS/nixpkgs/nixos-24.05
2

Reference the alternate input in devenv.nix

devenv.nix
{ pkgs, inputs, ... }:

{
  packages = [
    # Most packages from the default nixpkgs
    pkgs.git
    # This one pinned to the stable channel
    inputs.nixpkgs-stable.legacyPackages.${pkgs.system}.postgresql
  ];
}
Run devenv update after changing inputs in devenv.yaml to refresh the lock file.

Build docs developers (and LLMs) love