EvalStateBuilder

Struct EvalStateBuilder 

Source
pub struct EvalStateBuilder { /* private fields */ }
Expand description

Builder for configuring and creating an EvalState.

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

let store = Store::open(None, HashMap::new())?;

let mut es: EvalState = EvalStateBuilder::new(store)?
    .lookup_path(["nixpkgs=/path/to/nixpkgs", "home-manager=/path/to/hm"])?
    .build()?;

let value = es.eval_from_string("<nixpkgs>", /* path display: */ "in-memory")?;

Implementations§

Source§

impl EvalStateBuilder

Source

pub fn new(store: Store) -> Result<EvalStateBuilder>

Creates a new EvalStateBuilder.

Source

pub fn lookup_path<'a>( self, path: impl IntoIterator<Item = &'a str>, ) -> Result<Self>

Sets the lookup path for Nix expression evaluation.

Source

pub fn load_ambient_settings(self, load: bool) -> Self

Sets whether to load settings from the ambient environment.

When enabled (default), calls nix_eval_state_builder_load to load settings from NIX_CONFIG and other environment variables. When disabled, only the explicitly configured settings are used.

Source

pub fn build(&self) -> Result<EvalState>

Builds the configured EvalState.

Source

pub fn raw_ptr(&self) -> *mut eval_state_builder

Returns a raw pointer to the underlying eval state builder.

§Safety

The caller must ensure that the pointer is not used beyond the lifetime of this builder.

Trait Implementations§

Source§

impl Drop for EvalStateBuilder

Available on nix_at_least=2.26 only.
Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.