Store

Struct Store 

Source
pub struct Store { /* private fields */ }

Implementations§

Source§

impl Store

Source

pub fn open<'a, 'b>( url: Option<&str>, params: impl IntoIterator<Item = (&'a str, &'b str)>, ) -> Result<Self>

Open a store.

See nix_bindings_store_sys::store_open for more information.

Source

pub unsafe fn raw_ptr(&self) -> *mut Store

§Safety

The returned pointer is only valid as long as the Store is alive.

Source

pub fn get_uri(&mut self) -> Result<String>

Source

pub fn get_storedir(&mut self) -> Result<String>

Source

pub fn parse_store_path(&mut self, path: &str) -> Result<StorePath>

Source

pub fn real_path(&mut self, path: &StorePath) -> Result<String>

Source

pub fn derivation_from_json(&mut self, json: &str) -> Result<Derivation>

Parse a derivation from JSON.

Requires Nix 2.33 or later.

The JSON format follows the Nix derivation JSON schema. Note that this format is experimental as of writing. The derivation is not added to the store; use Store::add_derivation for that.

§Parameters
  • json: A JSON string representing the derivation
§Returns

A Derivation object if parsing succeeds, or an error if the JSON is invalid or malformed.

Source

pub fn add_derivation(&mut self, drv: &Derivation) -> Result<StorePath>

Add a derivation to the store.

Requires Nix 2.33 or later.

This computes the store path for the derivation and registers it in the store. The derivation itself is written to the store as a .drv file.

§Parameters
  • drv: The derivation to add
§Returns

The store path of the derivation (ending in .drv).

Source

pub fn realise( &mut self, path: &StorePath, ) -> Result<BTreeMap<String, StorePath>>

Build a derivation and return its outputs.

Requires Nix 2.33 or later.

This builds the derivation at the given store path and returns a map of output names to their realized store paths. The derivation must already exist in the store (see Store::add_derivation).

§Parameters
  • path: The store path of the derivation to build (typically ending in .drv)
§Returns

A BTreeMap mapping output names (e.g., “out”, “dev”, “doc”) to their store paths. The map is ordered alphabetically by output name for deterministic iteration.

Source

pub fn get_fs_closure( &mut self, store_path: &StorePath, flip_direction: bool, include_outputs: bool, include_derivers: bool, ) -> Result<Vec<StorePath>>

Get the closure of a specific store path.

Requires Nix 2.33 or later.

Computes the filesystem closure (dependency graph) of a store path, with options to control the direction and which related paths to include.

§Parameters
  • store_path: The path to compute the closure from
  • flip_direction: If false, compute the forward closure (paths referenced by this path). If true, compute the backward closure (paths that reference this path).
  • include_outputs: When flip_direction is false: for any derivation in the closure, include its outputs. When flip_direction is true: for any output in the closure, include derivations that produce it.
  • include_derivers: When flip_direction is false: for any output in the closure, include the derivation that produced it. When flip_direction is true: for any derivation in the closure, include its outputs.
§Returns

A vector of store paths in the closure, in no particular order.

Source

pub fn weak_ref(&self) -> StoreWeak

Trait Implementations§

Source§

impl Clone for Store

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

§

impl Freeze for Store

§

impl RefUnwindSafe for Store

§

impl !Send for Store

§

impl !Sync for Store

§

impl Unpin for Store

§

impl UnwindSafe for Store

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.