docs(nixgen): schemars-nixgen has a README, and the docs say how to run it

This commit is contained in:
LGUG2Z committed 2026-11-05 15:03:27 -08:00
1 parent a342dc39f5
commit b16fedebe7
2 files changed
+19 -2

No files matched your search

+17
View File
@@ -0,0 +1,17 @@
# schemars-nixgen
Writes Nix module options from a JSON Schema made by `schemars`. komorebi's NixOS and nix-darwin modules type their
`config` with the options it writes from `schemas/<platform>/schema.json`.
It is a development tool: no release ships it, and it is not a default member of the workspace, so a bare
`cargo build` leaves it out. Run it from the tree:
```sh
just nixgen-linux # nix/linux/komorebi-options.nix
just nixgen-macos # nix/macos/komorebi-options.nix and komorebi-bar-options.nix
```
The first line of what it writes is `# schema-sha256: <hash>`, the hash of the schema it was made from, which is how
the `linux-schema-fresh` check tells that the options are stale without running it.
`nix build .#schemars-nixgen` builds it, and `nix build .#checkSets.nixgen-lint .#checkSets.nixgen-test` check it.
+2 -2
View File
@@ -75,8 +75,8 @@ on machines built with the module too.
Three files are generated from the Rust types and committed: `schemas/linux/schema.json` and
`schemas/linux/schema.asc.json` (`just jsonschema`), and `nix/linux/komorebi-options.nix`, which types the
module's `config` (`just nixgen`, which needs `schemars-nixgen`, `cargo install
schemars-nixgen`). A change to what `komorebi.json` or an `applications.json` can
module's `config` (`just nixgen-linux`, which runs `schemars-nixgen`, built from
[`crates/schemars-nixgen`](../../crates/schemars-nixgen)). A change to what `komorebi.json` or an `applications.json` can
say regenerates them in the same commit, and the check `schema-fresh` fails when
it does not. The first line of the options file is the hash of the schema it was
made from, which is how the check tells without running `schemars-nixgen`.