Files
komorebi/Cargo.toml
T
LGUG2Z 7763d679a5 feat(nixgen): initial implementation of schemars-nixgen
This crate converts JSON Schema (as generated by schemars) into
strongly-typed Nix option definitions for the NixOS module system.

The primary motivation was to generate NixOS module options for komorebi
and komorebi-bar configurations, allowing users to write type-checked
Nix configurations that map directly to the JSON config files expected
by those applications.

Some high level notes on the implementation:

* Handles all common JSON Schema patterns including primitives, arrays,
  objects, enums, refs, oneOf/anyOf/allOf, and nullable types
* Detects and correctly generates externally-tagged unions (Rust's
  default serde enum representation) as submodules with optional fields
* Detects internally-tagged unions and mixed enum+object unions
* Generates let bindings for frequently-used type definitions to avoid
  repetition in the output (e.g., large enums like Base16Value)
* Uses topological sorting to generate type bindings in dependency order,
  ensuring nested refs are deduplicated correctly
* Handles patternProperties for index-based configuration patterns
2025-12-24 17:20:16 -08:00

22 lines
448 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" }
thiserror = "2"