pub struct DerivationBuilder {
pub arguments: Vec<String>,
pub command: String,
pub environment: BTreeMap<String, BString>,
pub input_derivations: BTreeMap<StorePath, BTreeSet<OutputName>>,
pub input_sources: BTreeSet<StorePath>,
pub outputs: OutputsBuilder,
pub system: String,
}Expand description
Builder for Derivation and UnverifiedDerivation.
This helps to build either a Derivation or a UnverifiedDerivation from
its component fields.
Since both Derivation and UnverifiedDerivation are immutable
this builder is needed to construct them from scratch.
The fields are public so that they can be mutated without any getters and setters. The fields don’t know about output paths for a derivation, only output names and whether it’s a FOD.
Once the fields are populated:
buildreturns a fully validatedDerivation. It takes the derivation name and the HDM lookup function, calculating output paths on its own.build_unverifiedreturns aUnverifiedDerivationIt takes Outputs, which can be constructed using the constructors there.
§Validation
When building a Derivation or an UnverifiedDerivation the following things are checked:
StorePathof input derivations end in.drv.systemis not empty.builderis not empty.- no environment variable name is empty.
In addition, if producing a Derivation, all of its invariants are checked as well.
Fields§
§arguments: Vec<String>Command line arguments to builder
command: StringCommand to execute. This is usually a path to bash.
NOTE: This is called builder in cppnix and in Nix code.
environment: BTreeMap<String, BString>Environment variables to include in build environmennt.
input_derivations: BTreeMap<StorePath, BTreeSet<OutputName>>Map from drv path to output names used from this derivation.
input_sources: BTreeSet<StorePath>Plain store paths of additional inputs.
outputs: OutputsBuilderBuilder for the outputs of this derivation.
system: StringSystem used to build this derivation.
Implementations§
Source§impl DerivationBuilder
impl DerivationBuilder
Sourcepub(super) fn serialize_with_replacements<'a, E, EK, EV, O, I, ID>(
&self,
writer: &mut impl Write,
environment: E,
outputs: O,
input_derivations_sorted: I,
) -> Result<(), Error>where
E: IntoIterator<Item = (EK, EV)>,
EK: AsRef<[u8]>,
EV: AsRef<[u8]>,
O: AtermWriteable,
I: Iterator<Item = (ID, &'a BTreeSet<OutputName>)>,
ID: AtermWriteable,
pub(super) fn serialize_with_replacements<'a, E, EK, EV, O, I, ID>(
&self,
writer: &mut impl Write,
environment: E,
outputs: O,
input_derivations_sorted: I,
) -> Result<(), Error>where
E: IntoIterator<Item = (EK, EV)>,
EK: AsRef<[u8]>,
EV: AsRef<[u8]>,
O: AtermWriteable,
I: Iterator<Item = (ID, &'a BTreeSet<OutputName>)>,
ID: AtermWriteable,
Like serialize, but allows replacing the environment, outputs and input_derivations for hash calculations.
This is used to render the ATerm representation of a Derivation “modulo fixed-output derivations”.
The passed environment, outputs and input_derivations MUST be sorted.
Source§impl DerivationBuilder
impl DerivationBuilder
Sourcepub(super) fn hash_derivation_modulo_with_outputs<O, L, E, EK, EV>(
&self,
environment: E,
outputs: &O,
lookup: L,
) -> Result<Sha256, DerivationError>where
E: IntoIterator<Item = (EK, EV)>,
EK: AsRef<[u8]>,
EV: AsRef<[u8]>,
O: AtermWriteable,
L: HashDerivationModuloLookup,
pub(super) fn hash_derivation_modulo_with_outputs<O, L, E, EK, EV>(
&self,
environment: E,
outputs: &O,
lookup: L,
) -> Result<Sha256, DerivationError>where
E: IntoIterator<Item = (EK, EV)>,
EK: AsRef<[u8]>,
EV: AsRef<[u8]>,
O: AtermWriteable,
L: HashDerivationModuloLookup,
Calculate HDM with provided environment variable and output replacements.
fn hash_derivation_modulo<L>(
&self,
lookup: L,
) -> Result<Sha256, DerivationError>where
L: HashDerivationModuloLookup,
Sourcepub fn calculate_outputs<L>(
&self,
name: &str,
lookup: L,
) -> Result<Outputs, DerivationError>where
L: HashDerivationModuloLookup,
pub fn calculate_outputs<L>(
&self,
name: &str,
lookup: L,
) -> Result<Outputs, DerivationError>where
L: HashDerivationModuloLookup,
Calculate and return Outputs for this DerivationBuilder.
This will also ensure that the OutputsBuilder is valid, and that
the provided name can be combined with the name of the output to
produce a valid StorePath.
To calculate the outputs paths for input addressed outputs we
need to lookup the hash derivation modulo of all input
derivations, which is done using the provided
HashDerivationModuloLookup.
Internally this calls store_path::build_ca_path or
store_path::build_output_path, depending on output type, to actually
make the StorePath.
Sourcepub fn build<L>(
self,
name: &str,
lookup: L,
) -> Result<Derivation, DerivationError>where
L: HashDerivationModuloLookup,
pub fn build<L>(
self,
name: &str,
lookup: L,
) -> Result<Derivation, DerivationError>where
L: HashDerivationModuloLookup,
Consume this builder and return the built Derivation if possible.
This will build the validated and full Derivation using the data from
this DerivationBuilder, the provided name and provided
HashDerivationModuloLookup.
Sourcepub fn build_unverified(
self,
outputs: Outputs,
) -> Result<UnverifiedDerivation, DerivationError>
pub fn build_unverified( self, outputs: Outputs, ) -> Result<UnverifiedDerivation, DerivationError>
Consume this builder and return a UnverifiedDerivation with the provided outputs.
This will validate and update environment variables for outputs to their store paths.
Trait Implementations§
Source§impl Clone for DerivationBuilder
impl Clone for DerivationBuilder
Source§fn clone(&self) -> DerivationBuilder
fn clone(&self) -> DerivationBuilder
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for DerivationBuilder
impl Debug for DerivationBuilder
Source§impl Default for DerivationBuilder
impl Default for DerivationBuilder
Source§fn default() -> DerivationBuilder
fn default() -> DerivationBuilder
Source§impl<'de> Deserialize<'de> for DerivationBuilder
impl<'de> Deserialize<'de> for DerivationBuilder
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl PartialEq for DerivationBuilder
impl PartialEq for DerivationBuilder
Source§fn eq(&self, other: &DerivationBuilder) -> bool
fn eq(&self, other: &DerivationBuilder) -> bool
self and other values to be equal, and is used by ==.impl Eq for DerivationBuilder
impl StructuralPartialEq for DerivationBuilder
Auto Trait Implementations§
impl Freeze for DerivationBuilder
impl RefUnwindSafe for DerivationBuilder
impl Send for DerivationBuilder
impl Sync for DerivationBuilder
impl Unpin for DerivationBuilder
impl UnsafeUnpin for DerivationBuilder
impl UnwindSafe for DerivationBuilder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.