Pinning Nixpkgs#

Specifying remote Nix expressions, such as the one provided by Nixpkgs, can be done in several ways:

Possible URL values#

  • Local file path:


    Using ./. means that the expression is located in a file default.nix in the current directory.

  • Pinned to a specific commit:
  • Using the latest channel version, meaning all tests have passed:
  • Shorthand syntax for channels:

  • Using the latest channel version, hosted by GitHub:
  • Using the latest commit on the release branch, but not tested yet:


  • $ nix-build -I ~/dev
  • $ nix-build -I nixpkgs=
  • $ nix-build -I nixpkgs=channel:nixos-22.11
  • $ NIX_PATH=nixpkgs= nix-build
  • $ NIX_PATH=nixpkgs=channel:nixos-22.11 nix-build
  • In the Nix language:

    2  pkgs = import (fetchTarball "") {};
    3in pkgs.stdenv.mkDerivation { ... }