EvalStateBuilder: Specify Nix version constraint

This commit is contained in:
Robert Hensing 2026-01-07 09:20:01 +01:00
parent 7eb94b72f9
commit 22480afeb5
4 changed files with 68 additions and 42 deletions

View file

@ -2,6 +2,7 @@
name = "nix-bindings-expr"
version = "0.1.0"
edition = "2021"
build = "build.rs"
license = "LGPL-2.1"
description = "Rust bindings to Nix expression evaluator"
repository = "https://github.com/nixops4/nix-bindings-rust"
@ -19,6 +20,10 @@ ctor = "0.2"
tempfile = "3.10"
cstr = "0.2"
[build-dependencies]
pkg-config = "0.3"
nix-bindings-util = { path = "../nix-bindings-util" }
[lints.rust]
warnings = "deny"
dead-code = "allow"

View file

@ -0,0 +1,6 @@
use nix_bindings_util::nix_version::emit_version_cfg;
fn main() {
let nix_version = pkg_config::probe_library("nix-expr-c").unwrap().version;
emit_version_cfg(&nix_version, &["2.26"]);
}

View file

@ -224,6 +224,8 @@ impl Drop for EvalStateRef {
/// Provides advanced configuration options for evaluation context setup.
/// Use [`EvalState::new`] for simple cases or this builder for custom configuration.
///
/// Requires Nix 2.26.0 or later.
///
/// # Examples
///
/// ```rust
@ -244,11 +246,13 @@ impl Drop for EvalStateRef {
/// # Ok(())
/// # }
/// ```
#[cfg(nix_at_least = "2.26")]
pub struct EvalStateBuilder {
eval_state_builder: *mut raw::eval_state_builder,
lookup_path: Vec<CString>,
store: Store,
}
#[cfg(nix_at_least = "2.26")]
impl Drop for EvalStateBuilder {
fn drop(&mut self) {
unsafe {
@ -256,6 +260,7 @@ impl Drop for EvalStateBuilder {
}
}
}
#[cfg(nix_at_least = "2.26")]
impl EvalStateBuilder {
/// Creates a new [`EvalStateBuilder`].
pub fn new(store: Store) -> Result<EvalStateBuilder> {