Expand description
ronix — Serialize Rust structs to Nix expressions and convert RON to Nix.
Provides a custom serde [Serializer] that converts any Serialize type
into a Nix expression string. Also provides direct RON string to Nix
conversion via ron_to_nix and ron_to_nix_module.
§Examples
use serde::Serialize;
#[derive(Serialize)]
struct Config {
poll_interval_ms: u64,
name: String,
enabled: bool,
}
let config = Config {
poll_interval_ms: 2000,
name: "test".into(),
enabled: true,
};
let nix = ronix::to_nix(&config).unwrap();
assert!(nix.contains("poll_interval_ms = 2000;"));
assert!(nix.contains("name = \"test\";"));
assert!(nix.contains("enabled = true;"));Enums§
Functions§
- escape_
nix_ string - ron_
to_ nix - Parse a RON string and serialize it to a Nix expression.
- ron_
to_ nix_ module - Parse a RON string and serialize it as a NixOS module.
- to_nix
- Serialize any serde value to a Nix expression string.
- to_
nix_ module - Serialize to a complete NixOS module wrapping the value under an attribute path.