Nix 2.36.0
Nix, the purely functional package manager; unstable internal interfaces
Loading...
Searching...
No Matches
nix::Builder Struct Referenceabstract

#include <build.hh>

Inheritance diagram for nix::Builder:
nix::LegacySSHBuilder nix::LocalBuilder nix::RemoteBuilder nix::RestrictedBuilder nix::Worker

Public Member Functions

virtual void anchor ()
virtual void buildPaths (const std::vector< DerivedPath > &reqs, BuildMode buildMode=bmNormal)=0
virtual std::vector< KeyedBuildResult > buildPathsWithResults (const std::vector< DerivedPath > &reqs, BuildMode buildMode=bmNormal)=0
virtual BuildResult buildDerivation (const StorePath &drvPath, const BasicDerivation &drv, BuildMode buildMode=bmNormal)=0
virtual void ensurePath (const StorePath &path)=0
virtual void repairPath (const StorePath &path)=0

Detailed Description

Abstract interface for the build scheduler entry points.

Worker implements this for local scheduling, including local builds. Remote stores provide a Builder via Store::getBuilder().

Thread safety should be guaranteed across these methods.

Member Function Documentation

◆ buildDerivation()

virtual BuildResult nix::Builder::buildDerivation ( const StorePath & drvPath,
const BasicDerivation & drv,
BuildMode buildMode = bmNormal )
pure virtual

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).

Implemented in nix::LegacySSHBuilder, nix::LocalBuilder, nix::RemoteBuilder, nix::RestrictedBuilder, and nix::Worker.

◆ buildPaths()

virtual void nix::Builder::buildPaths ( const std::vector< DerivedPath > & reqs,
BuildMode buildMode = bmNormal )
pure virtual

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.

Implemented in nix::LegacySSHBuilder, nix::LocalBuilder, nix::RemoteBuilder, nix::RestrictedBuilder, and nix::Worker.

◆ buildPathsWithResults()

virtual std::vector< KeyedBuildResult > nix::Builder::buildPathsWithResults ( const std::vector< DerivedPath > & reqs,
BuildMode buildMode = bmNormal )
pure virtual

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.

Implemented in nix::LegacySSHBuilder, nix::LocalBuilder, nix::RemoteBuilder, nix::RestrictedBuilder, and nix::Worker.

◆ ensurePath()

virtual void nix::Builder::ensurePath ( const StorePath & path)
pure virtual

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.

Implemented in nix::LegacySSHBuilder, nix::LocalBuilder, nix::RemoteBuilder, nix::RestrictedBuilder, and nix::Worker.

◆ repairPath()

virtual void nix::Builder::repairPath ( const StorePath & path)
pure virtual

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

Implemented in nix::LegacySSHBuilder, nix::LocalBuilder, nix::RemoteBuilder, nix::RestrictedBuilder, and nix::Worker.


The documentation for this struct was generated from the following files:
  • libstore/include/nix/store/build.hh
  • libstore/store-api.cc