feat: nix_expr::value::__private

Exposes the Value constructors, for use by other bindings like
nix-flake, which needs to construct e.g. a flake outputs Value.

See https://github.com/nixops4/nixops4/issues/25

> We have two related issues:

> A bunch of implementation details cannot be made private, since they must be used from one of the other crates (e.g. Values are defined in the value module but used from eval_state
> While we don't want users to need to use these features, it may be good to provide escape hatches so they can interface with the raw API if they need more control.
> Problem (1) has been solved in other crates with a __private module with #[doc(hidden)] set. See for instance:

I'm leaving docs turned on for (2). The issue has more thoughts about
alternatives.

(cherry picked from commit eb6744d1519febe5b6aa6233eb3f3e8a049f12d4)
This commit is contained in:
Robert Hensing 2025-04-02 18:49:03 +02:00
parent bbf245ef1a
commit e6b993a42b
2 changed files with 15 additions and 0 deletions

View file

@ -1,3 +1,5 @@
pub mod __private;
use nix_c_raw as raw;
use nix_util::{check_call, context::Context};
use std::ptr::{null_mut, NonNull};

View file

@ -0,0 +1,13 @@
//! Functions that are relevant for other bindings modules, but normally not end users.
use super::Value;
use nix_c_raw as raw;
/// See [Value::new].
pub unsafe fn raw_value_new(ptr: *mut raw::Value) -> Value {
Value::new(ptr)
}
/// See [Value::new_borrowed].
pub unsafe fn raw_value_new_borrowed(ptr: *mut raw::Value) -> Value {
Value::new_borrowed(ptr)
}