Nix 2.36.0
Nix, the purely functional package manager; unstable internal interfaces
Loading...
Searching...
No Matches
nix::DerivationBuilderImpl Class Reference

#include <derivation-builder-impl.hh>

Inheritance diagram for nix::DerivationBuilderImpl:
nix::DerivationBuilder nix::DerivationBuilderParams nix::RestrictionContext nix::UnixDerivationBuilderImpl nix::ChrootDerivationBuilder nix::DarwinDerivationBuilder nix::FreeBSDDerivationBuilder nix::LinuxDerivationBuilder nix::ChrootFreeBSDDerivationBuilder nix::ChrootLinuxDerivationBuilder nix::ChrootFreeBSDDerivationBuilder nix::ChrootLinuxDerivationBuilder

Public Member Functions

 DerivationBuilderImpl (std::shared_ptr< BuildingStore > store, std::shared_ptr< DerivationBuilderCallbacks > miscMethods, DerivationBuilderParams params)
SingleDrvOutputs registerOutputs (LocalStore &localStore) override
SingleDrvOutputs checkSubmittedOutputs (LocalStore &localStore) override
Public Member Functions inherited from nix::DerivationBuilder
MuxablePipePollState::CommChannel logChannel ()
Descriptor logDescriptor ()
virtual std::optional< Descriptor > startBuild ()=0
virtual BuilderExit unprepareBuild ()=0
virtual void cleanupBuild (bool force)=0
virtual bool killChild ()=0
Public Member Functions inherited from nix::RestrictionContext
virtual const StorePathSet & originalPaths ()=0
virtual bool isAllowed (const StorePath &)=0
virtual bool isAllowed (const DrvOutput &id)=0
bool isAllowed (const DerivedPath &id)
virtual bool shouldModifySandbox ()=0
virtual void submitOutput (const SingleDerivedPath &path, const OutputName &output)=0
void addDependency (const StorePath &path)

Public Attributes

Sync< OutputPathMap > submittedOutputs
Public Attributes inherited from nix::DerivationBuilder
AutoCloseFD builderOut
Public Attributes inherited from nix::RestrictionContext
Sync< State > state_
Public Attributes inherited from nix::DerivationBuilderParams
const StorePath & drvPath
BuildResult & buildResult
const BasicDerivation & drv
const DerivationOptions< StorePath > & drvOptions
const StorePathSet & inputPaths
const std::map< std::string, InitialOutput > initialOutputs
const BuildMode & buildMode
PathsInChroot defaultPathsInChroot
StringSet systemFeatures
DesugaredEnv desugaredEnv

Protected Types

typedef std::map< StorePath, StorePath > RedirectedOutputs

Protected Member Functions

virtual std::filesystem::path realPathInHost (const StorePath &p)
Protected Member Functions inherited from nix::RestrictionContext
virtual void addDependencyImpl (const StorePath &path)=0

Protected Attributes

Pid pid
std::shared_ptr< BuildingStore > store
std::shared_ptr< DerivationBuilderCallbacks > miscMethods
std::filesystem::path tmpDir
const derivation::Type derivationType
const LocalSettings & localSettings = store->getLocalSettings()
std::unique_ptr< UserLock > buildUser
StringMap inputRewrites
StringMap outputRewrites
RedirectedOutputs redirectedOutputs
OutputPathMap scratchOutputs

Detailed Description

The state for building locally that does not depend on the platform, and registerOutputs, which every implementation ends with.

The platform-specific subclasses — UnixDerivationBuilderImpl and WindowsDerivationBuilderImpl — own everything about running the builder: sandboxing, build users, and recursive Nix are all Unix-only so far.

Todo
This should not be a class. registerOutputs wants to be a function over the state it reads, which is most of what is here.

Member Function Documentation

◆ checkSubmittedOutputs()

SingleDrvOutputs nix::DerivationBuilderImpl::checkSubmittedOutputs ( LocalStore & store)
overridevirtual

Check that the derivation outputs submitted by recursive-nix exist and attach them to the derivation.

Only used with builder-rpc-v0.

Implements nix::DerivationBuilder.

◆ realPathInHost()

virtual std::filesystem::path nix::DerivationBuilderImpl::realPathInHost ( const StorePath & p)
inlineprotectedvirtual

Where an output path lives while the build runs.

Sandboxing can put it somewhere other than its final home, so this is a hook rather than just Store::toRealPath.

Reimplemented in nix::ChrootDerivationBuilder.

◆ registerOutputs()

SingleDrvOutputs nix::DerivationBuilderImpl::registerOutputs ( LocalStore & store)
overridevirtual

Check that the derivation outputs all exist and register them as valid.

Not used with builder-rpc-v0; see checkSubmittedOutputs.

References to other outputs. Built by looking up in scratchOutputsInverse.

Implements nix::DerivationBuilder.

Member Data Documentation

◆ buildUser

std::unique_ptr<UserLock> nix::DerivationBuilderImpl::buildUser
protected

User selected for running the builder.

◆ derivationType

const derivation::Type nix::DerivationBuilderImpl::derivationType
protected

The sort of derivation we are building.

Just a cached value, computed from drv.

◆ inputRewrites

StringMap nix::DerivationBuilderImpl::inputRewrites
protected

Hash rewriting.

◆ pid

Pid nix::DerivationBuilderImpl::pid
protected

The process ID of the builder.

◆ scratchOutputs

OutputPathMap nix::DerivationBuilderImpl::scratchOutputs
protected

The output paths used during the build.

  • Input-addressed derivations or fixed content-addressed outputs are sometimes built when some of their outputs already exist, and can not be hidden via sandboxing. We use temporary locations instead and rewrite after the build. Otherwise the regular predetermined paths are put here.
  • Floating content-addressing derivations do not know their final build output paths until the outputs are hashed, so random locations are used, and then renamed. The randomness helps guard against hidden self-references.

◆ submittedOutputs

Sync<OutputPathMap> nix::DerivationBuilderImpl::submittedOutputs

Output paths from the SubmitOutput store command

◆ tmpDir

std::filesystem::path nix::DerivationBuilderImpl::tmpDir
protected

The temporary directory used for the build.


The documentation for this class was generated from the following files: