fixed-output derivations

A fixed-output derivation is one whose cryptographic hash is known ahead of time.

The derivations generated by fetchurl and related Nix functions are fixed-output derivations. This allows for source tarballs and similar files to be downloaded to the Nix store without breaking every dependent when a source mirror or other metadata gets updated.

The store path is determined entirely by the hash of the name and outputHash* attributes, rather than by the hash of all Components of a Nix derivation.

When writing derivations this way, use

  • outputHashMode - one of "flat" (a hash of the file) or "recursive" (a hash of the NAR archive dump of the source)
  • outputHashAlgo - one of sha1, sha256, or sha512
  • outputHash - the actual result hash, either in hexadecimal or base-32

fetchurl uses "flat" and sha256.