nix-hash
Installation
SKILL.md
Nix Hash
Hash Formats in Nix
Nix uses several hash encodings:
- SRI (
sha256-BASE64) — The modern standard, used infetchFromGitHub,fetchurl, etc. Format:<algo>-<base64> - Hex / base16 (
84a5d14c...) — The encoding most upstream projects publish - Base32 (
020ay2q1...) — Nix-specific legacy encoding; still printed by default bynix-prefetch-url
SRI is the preferred format. Always use SRI hashes in new derivations.
Flat vs NAR Hashes
Which bytes get hashed depends on how the fetcher consumes the source:
- Raw file bytes ("flat") — matches plain
fetchurl(nounpack = true). Compute withnix hash file. - NAR serialisation of an unpacked tree — matches
fetchFromGitHub,fetchzip, and any fetcher withunpack = true. Compute withnix hash path.