mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-11-28 03:12:46 +01:00
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`.
23 lines
462 B
TOML
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"
|