Nix 2.36.0
Nix, the purely functional package manager; unstable internal interfaces
Loading...
Searching...
No Matches
nix::RestrictedBuilder Struct Reference
Inheritance diagram for nix::RestrictedBuilder:
nix::Builder

Public Member Functions

 RestrictedBuilder (Worker &inner, RestrictionContext &goal)
void buildPaths (const std::vector< DerivedPath > &paths, BuildMode buildMode) override
std::vector< KeyedBuildResult > buildPathsWithResults (const std::vector< DerivedPath > &paths, BuildMode buildMode) override
BuildResult buildDerivation (const StorePath &drvPath, const BasicDerivation &drv, BuildMode buildMode) override
void ensurePath (const StorePath &path) override
void repairPath (const StorePath &path) override
Public Member Functions inherited from nix::Builder
virtual void anchor ()

Public Attributes

Worker & inner
RestrictionContext & goal

Detailed Description

A builder that wraps an inner builder, adding restriction checks and dependency tracking for recursive Nix builds.

Member Function Documentation

◆ buildDerivation()

BuildResult nix::RestrictedBuilder::buildDerivation ( const StorePath & drvPath,
const BasicDerivation & drv,
BuildMode buildMode )
overridevirtual

Build a single non-materialized derivation (i.e. not from an on-disk .drv file).

Parameters
drvPathThis is used to deduplicate worker goals so it is imperative that is correct. That said, it doesn't literally need to be store path that would be calculated from writing this derivation to the store: it is OK if it instead is that of a Derivation which would resolve to this (by taking the outputs of it's input derivations and adding them as input sources) such that the build time referenceable-paths are the same.

In the input-addressed case, we usually do use an "original" unresolved derivations's path, as that is what will be used in the buildPaths case. Also, the input-addressed output paths are verified only by that contents of that specific unresolved derivation, so it is nice to keep that information around so if the original derivation is ever obtained later, it can be verified whether the trusted user in fact used the proper output path.

In the content-addressed case, we want to always use the resolved drv path calculated from the provided derivation. This serves two purposes:

  • It keeps the operation trustless, by ruling out a maliciously invalid drv path corresponding to a non-resolution-equivalent derivation.
  • For the floating case in particular, it ensures that the derivation to output mapping respects the resolution equivalence relation, so one cannot choose different resolution-equivalent derivations to subvert dependency coherence (i.e. the property that one doesn't end up with multiple different versions of dependencies without explicitly choosing to allow it).

Implements nix::Builder.

◆ buildPaths()

void nix::RestrictedBuilder::buildPaths ( const std::vector< DerivedPath > & reqs,
BuildMode buildMode )
overridevirtual

For each path, if it's a derivation, build it. Building a derivation means ensuring that the output paths are valid. If they are already valid, this is a no-op. Otherwise, validity can be reached in two ways. First, if the output paths is substitutable, then build the path that way. Second, the output paths can be created by running the builder, after recursively building any sub-derivations. For inputs that are not derivations, substitute them.

Implements nix::Builder.

◆ buildPathsWithResults()

std::vector< KeyedBuildResult > nix::RestrictedBuilder::buildPathsWithResults ( const std::vector< DerivedPath > & reqs,
BuildMode buildMode )
overridevirtual

Like buildPaths(), but return a vector of BuildResult BuildResults corresponding to each element in paths. Note that in case of a build/substitution error, this function won't throw an exception, but return a BuildResult containing an error message.

Implements nix::Builder.

◆ ensurePath()

void nix::RestrictedBuilder::ensurePath ( const StorePath & path)
overridevirtual

Ensure that a path is valid. If it is not currently valid, it may be made valid by running a substitute (if defined for the path).

The path is registered as a temporary GC root first, whether or not it was already valid, so that a concurrent garbage collection cannot delete it while the caller is still using it.

Implements nix::Builder.

◆ repairPath()

void nix::RestrictedBuilder::repairPath ( const StorePath & path)
overridevirtual

Repair the contents of the given path by redownloading it using a substituter (if available).

Implements nix::Builder.


The documentation for this struct was generated from the following file:
  • libstore/restricted-store.cc