Expand description
High-level, safe Rust bindings for the Nix build tool.
This crate provides ergonomic and idiomatic Rust APIs for interacting with Nix using its C API.
§Quick Start
use std::sync::Arc;
use nix_bindings::{Context, EvalStateBuilder, Store};
let ctx = Arc::new(Context::new()?);
let store = Arc::new(Store::open(&ctx, None)?);
let state = EvalStateBuilder::new(&store)?.build()?;
let result = state.eval_from_string("1 + 2", "<eval>")?;
println!("Result: {}", result.as_int()?);§Value Formatting
Values support multiple formatting options:
let value = state.eval_from_string("\"hello world\"", "<eval>")?;
// Display formatting (user-friendly)
println!("{}", value); // Output: hello world
// Debug formatting (with type info)
println!("{:?}", value); // Output: Value::String("hello world")
// Nix syntax formatting
println!("{}", value.to_nix_string()?); // Output: "hello world"
//Structs§
- Context
- Nix context for managing library state.
- Eval
State - Nix evaluation state for evaluating expressions.
- Eval
State Builder - Builder for Nix evaluation state.
- Store
- Nix store for managing packages and derivations.
- Store
Path - A path in the Nix store.
- Value
- A Nix value.
Enums§
Type Aliases§
- Result
- Result type for Nix operations.