Skip to main content

Module source

Module source 

Source
Expand description

Source-tree store-path computation — the primitive behind builtins.getFlake "path:...".

CppNix, when asked for a path: flake ref, serializes the source tree as a NAR archive (excluding .git by default), hashes the NAR with sha256, and produces:

  • a store path of the form /nix/store/<hash>-source (computed via the fixed-output-hash “source” branch),
  • a SRI-format narHash of the form sha256-<base64>.

Both are surfaced on the flake result as outPath + narHash (top level) and duplicated inside sourceInfo.

This module is the single place we serialize + hash a source tree. Callers (currently just the flake evaluator in sui-eval) go through one function and get both outputs atomically — no chance of the hash drifting from the path.

Structs§

SourceHash
Result of serializing + hashing a source tree.

Functions§

base64_sha256
Base64 encode the SHA-256 of bytes without the sha256- prefix. Exposed for callers that already have NAR bytes in hand (e.g. a cache hit).
nar_hash_source_tree
NAR-serialize dir, hash it, and compute the CppNix source store path + SRI narHash.