Files
komorebi/Cargo.toml
T
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

23 lines
462 B
TOML

[package]
name = "schemars-nixgen"
version = "0.1.0"
edition = "2024"
license-file = "LICENSE.md"
[lib]
name = "schemars_nixgen"
path = "src/lib.rs"
[[bin]]
name = "schemars-nixgen"
path = "src/main.rs"
[dependencies]
clap = { version = "4", features = ["derive", "wrap_help"] }
color-eyre = "0.6"
schemars = "1.1"
serde = { version = "1", features = ["derive"] }
serde_json = { package = "serde_json_lenient", version = "0.2" }
sha2 = "0.10"
thiserror = "2"