Skip to main content

Crate ronix

Crate ronix 

Source
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§

Error

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.