Pinning Nixpkgs

Pinning Nixpkgs

Different ways:

  • As environment variable: $NIX_PATH=URL

  • -I command line parameter to most of commands like nix-build, nix-shell, etc

  • Using builtins.fetchTarball function that fetches the channel at evaluation time

Possible URL values

  • Local file path. Using just . means that nixpkgs is located in current folder.

  • Pinned to a specific commit:

  • Using latest channel, meaning all tests have passed:

  • Using latest channel, but hosted by github:

  • Using latest commit for release branch, but not tested yet:


  • nix-build -I ~/dev

  • nix-build -I nixpkgs=

  • NIX_PATH=nixpkgs= nix-build ...

  • Using just Nix:

      pkgs = import (fetchTarball "") {};
    in pkgs.stdenv.mkDerivation { … }
  • To make ad-hoc environment available on NixOS: nix.nixPath = [ ("nixpkgs=" + toString pkgs.path) ];