LGUG2Z 50ce2860c9 feat(nixgen): write the hash of the schema as the first line of the output
Consumers that check whether generated options are older than their schema
(komorebi-for-kde's `schema-fresh`) compare a `# schema-sha256: <hex>` first
line with the hash of schema.json. That line was added by hand in the
consumer's justfile with `printf` and `nix hash file`, so the tool's own output
could never pass the check.

Write the line from the tool. `schema_hash_header` returns it for the raw bytes
of the schema file, in lowercase hex, which is the digest `nix hash file --type
sha256 --base16` prints. The binary puts it before the generated code; the
library functions that return generated code are unchanged, so library users get
no new line unless they ask for it.

Adds the sha2 dependency.

Verified: cargo test passes (49, including two known SHA-256 vectors). On the
komorebi-for-kde schema.json the first line equals `nix hash file --type sha256
--base16 schema.json`.
2026-10-31 08:40:11 -07:00
S
Description
No description provided
47 MiB
0 Stars 1 Watchers 0 Forks
Latest
2026-02-14 21:52:25 +01:00
Languages
Rust 98.2%
Python 0.6%
AutoHotkey 0.5%
Nix 0.5%
Just 0.2%