memo.d.foundation / topics / devbox / research / pinning-nixpkgsConnect

Research notes/Platform ops

Pinning nixpkgs in Nix

An explanation of pinning nixpkgs in Nix and its importance for reproducible builds

Words
98

Pinning nixpkgs means you can choose the version of nixpkgs, and then all packages required for building your application and its dependencies are fetched from this nixpkgs version where the version of each package is specified and not changed over time.

let
  nixpkgs = fetchTarball {
    url = "https://github.com/NixOS/nixpkgs/archive/20.09.tar.gz";
    sha256 = "1wg61h4gndm3vcprdcg7rc4s1v3jkm5xd7lw8r2f67w502y94gcy";
  };
  pkgs = import nixpkgs {};
in

What happens once you do not specify the pinning version of nixpkgs? In this case, Nix uses your local nixpkgs version by default.


References

FAQ/Pinning Nixpkgs. (n.d.). NixOS Wiki. Retrieved August 2, 2024, from https://nixos.wiki/wiki/FAQ/Pinning_Nixpkgs

Dwarves Foundation memo. Written by the team and guest writers.Press [ or ] to move between headings