forked from fediversity/module-schema
Generate JSON schema for Nix modules
- Nix 100%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
Every branch of `typeToSchema'` converts an option type into a schema, which works because the option type is the source of truth and the schema is derived from it. For a service that publishes the schema of its own configuration file the direction is reversed: the schema is upstream's, the option type is ours, and converting the schema into option types loses whatever the option-type vocabulary cannot express -- `pattern` most plainly, a Nix regex predicate having no faithful translation, but also every keyword from a draft that postdates the converter. Let a type say it was built from a schema, by carrying that schema in `functor.payload.jsonSchema`, and emit the carried schema instead of converting the type. The carry wins over the name-keyed branches: a type built from a schema may still answer to a familiar `name`, and the schema is the more faithful of the two answers. `$defs` are the one thing not carried verbatim. A `$ref` is anchored at the root of the document it ends up in, so carried definitions have to join the ones the surrounding walk accumulated, at the top level, under the names their `$ref`s already use. Two differing definitions sharing a name cannot both survive that lift, so the clash is refused rather than silently resolved. Assisted-by: Claude:claude-opus-5 |
||
| lib | ||
| notes | ||
| npins | ||
| .gitignore | ||
| LICENSE | ||
| README.md | ||
| shell.nix | ||
module-schema
Generate JSON schema for NixOS modules