Skip to content

Inputs

Inputs allow you to refer to Nix code outside of your project while preserving reproducibility.

Think of inputs as dependency management for your developer environment.

If you omit devenv.yaml, it defaults to:

devenv.yaml
inputs:
  nixpkgs:
    url: github:cachix/devenv-nixpkgs/rolling
  git-hooks:
    url: github:cachix/git-hooks.nix

The dependencies you mention as inputs are passed as an argument to the function.

For example, if you have a devenv.yaml file like:

devenv.yaml
inputs:
  nixpkgs-stable:
    url: github:NixOS/nixpkgs/nixos-23.11

You can access the stable packages via the inputs field:

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

let
  pkgs-stable = import inputs.nixpkgs-stable { system = pkgs.stdenv.system; };
in {
  packages = [ pkgs-stable.git ];

  enterShell = ''
    git --version
  ''
}

See basics for more about devenv.nix.

There are a few special inputs passed into devenv.nix:

devenv.nix
{ pkgs, lib, config, ... }:

{
  env.GREET = "hello";

  enterShell = ''
    echo ${config.env.GREET}
  '';
}

Note

... is a catch-all pattern for any additional inputs, so you can safely omit the inputs you're not using.

See devenv.yaml reference for all supported inputs.

Locking and updating inputs

When you run any of the commands, devenv resolves inputs like github:NixOS/nixpkgs/nixpkgs-unstable into a commit revision and writes them to devenv.lock. This ensures that your environment is reproducible.

To update an input to a newer commit, run devenv update or read the devenv.yaml reference to learn how to pin down the revision/branch at the input level.