Skip to main content

Crate nixcfg

Crate nixcfg 

Source
Expand description

nixcfg - bridge config structs to NixOS module options via JSON Schema

use #[derive(JsonSchema)] from schemars with #[schemars(extend(...))] to annotate fields with nixcfg extensions:

  • #[schemars(extend("x-nixcfg-secret" = true))] for secret fields
  • #[schemars(extend("x-nixcfg-port" = true))] for port types

then emit the schema with NixSchema::from::<T>("name"), or use the one-liner [emit::<T>("name")] when T: JsonSchema + Default + Serialize

Re-exports§

pub use schemars;
pub use serde_json;

Structs§

NixSchema
wraps a schemars-generated JSON Schema with nixcfg metadata

Traits§

JsonSchema
A type which can be described as a JSON Schema document.

Functions§

emit
emit a schema for T as pretty JSON, with defaults from T::default() merged in. this is the one-liner equivalent of the idiomatic emitter binary every downstream project writes

Attribute Macros§

nixcfg
attribute macro that rewrites #[nixcfg(...)] field attributes into #[schemars(extend(...))] for nixcfg extension properties

Derive Macros§

JsonSchema
Derive macro for JsonSchema trait.