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

#include <derivation-builder.hh>

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

Public Member Functions

MuxablePipePollState::CommChannel logChannel ()
Descriptor logDescriptor ()
virtual std::optional< Descriptor > startBuild ()=0
virtual BuilderExit unprepareBuild ()=0
virtual SingleDrvOutputs registerOutputs (LocalStore &store)=0
virtual SingleDrvOutputs checkSubmittedOutputs (LocalStore &store)=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

AutoCloseFD builderOut
Public Attributes inherited from nix::RestrictionContext
Sync< State > state_

Additional Inherited Members

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

Detailed Description

This class represents the state for building locally.

Todo
Ideally, it would not be a class, but a single function. However, besides the main entry point, there are a few more methods which are externally called, and need to be gotten rid of. There are also some virtual methods (either directly here or inherited from DerivationBuilderCallbacks, a stop-gap) that represent outgoing rather than incoming call edges that either should be removed, or become (higher order) function parameters.

Member Function Documentation

◆ checkSubmittedOutputs()

virtual SingleDrvOutputs nix::DerivationBuilder::checkSubmittedOutputs ( LocalStore & store)
pure virtual

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

Only used with builder-rpc-v0.

Implemented in nix::DerivationBuilderImpl.

◆ cleanupBuild()

virtual void nix::DerivationBuilder::cleanupBuild ( bool force)
pure virtual

Delete the temporary directory, if we have one.

Parameters
forceWe know the build succeeded, so don't attempt to preserve anything for debugging.

Implemented in nix::ChrootDerivationBuilder, nix::ChrootFreeBSDDerivationBuilder, and nix::UnixDerivationBuilderImpl.

◆ killChild()

virtual bool nix::DerivationBuilder::killChild ( )
pure virtual

Forcibly kill the child process, if any.

Returns
whether the child was still alive and needed to be killed.

Implemented in nix::UnixDerivationBuilderImpl.

◆ logChannel()

MuxablePipePollState::CommChannel nix::DerivationBuilder::logChannel ( )
inline

What the worker should wait on for this build's log.

◆ logDescriptor()

Descriptor nix::DerivationBuilder::logDescriptor ( )
inline

The descriptor a ChildOutput event for this build's log carries.

◆ registerOutputs()

virtual SingleDrvOutputs nix::DerivationBuilder::registerOutputs ( LocalStore & store)
pure virtual

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

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

Implemented in nix::DerivationBuilderImpl.

◆ startBuild()

virtual std::optional< Descriptor > nix::DerivationBuilder::startBuild ( )
pure virtual

Set up build environment / sandbox, acquiring resources (e.g. locks as needed). After this is run, the builder should be started.

Returns
logging pipe if successful, std::nullopt if we could not acquire a build user. In that case, the caller must wait and then try again.
Note
"success" just means that we were able to set up the environment and start the build. The builder could have immediately exited with failure, and that would still be considered a successful start.

Implemented in nix::UnixDerivationBuilderImpl.

◆ unprepareBuild()

virtual BuilderExit nix::DerivationBuilder::unprepareBuild ( )
pure virtual

Tear down build environment after the builder exits (either on its own or if it is killed).

Returns
The builder's exit status and whether the disk seemed full at exit time.

Implemented in nix::ChrootLinuxDerivationBuilder, and nix::UnixDerivationBuilderImpl.

Member Data Documentation

◆ builderOut

AutoCloseFD nix::DerivationBuilder::builderOut

Where the builder's standard output/error is read from, set by startBuild.

The two platforms cannot share a type here: Unix hands out the master side of a pseudoterminal, whereas nix::windows::MuxablePipePollState::iterate needs the pipe's OVERLAPPED state and buffer, which a Descriptor does not carry.


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