Pinning dependencies

Fixing a Nix dependency to a specific revision

Concepts / Pinning dependencies

Pinning a dependency refers to the act of specifying an exact revision for Nix to use. This is particularly interesting in relation to Nix's reproducibility guarantees.

When you pin Nix dependencies to a specific revision you are guaranteed to get the same outputs of builds, based on the same inputs, which can not change. This is particularly useful when sharing environments between different developers, or between a development and production environment.

Pinning dependencies can be done in the inputs section of the flakes file:

{
  inputs = {
    nixpkgs.url = "git+https://github:nixos/nixpkgs?rev=fdc8ef970de2b4634e1b3dca296e1ed918459a9e";
  };
}

Was this page helpful?