Nix 2.26.3
Nix, the purely functional package manager; unstable internal interfaces
 
Loading...
Searching...
No Matches
nix::DerivationGoal Struct Reference

#include <derivation-goal.hh>

Inheritance diagram for nix::DerivationGoal:
nix::Goal

Public Types

enum struct  NeedRestartForMoreOutputs { OutputsUnmodifedDontNeed , OutputsAddedDoNeed , BuildInProgressWillNotNeed }
 
enum  RetrySubstitution { NoNeed , YesNeed , AlreadyRetried }
 
- Public Types inherited from nix::Goal
enum  ExitCode {
  ecBusy , ecSuccess , ecFailed , ecNoSubstituters ,
  ecIncompleteClosure
}
 
using handle_type = std::coroutine_handle<promise_type>
 

Public Member Functions

 DerivationGoal (const StorePath &drvPath, const OutputsSpec &wantedOutputs, Worker &worker, BuildMode buildMode=bmNormal)
 
 DerivationGoal (const StorePath &drvPath, const BasicDerivation &drv, const OutputsSpec &wantedOutputs, Worker &worker, BuildMode buildMode=bmNormal)
 
void timedOut (Error &&ex) override
 
std::string key () override
 
void addWantedOutputs (const OutputsSpec &outputs)
 
Co init () override
 
Co getDerivation ()
 
Co loadDerivation ()
 
Co haveDerivation ()
 
Co outputsSubstitutionTried ()
 
Co gaveUpOnSubstitution ()
 
Co closureRepaired ()
 
Co inputsRealised ()
 
Co tryToBuild ()
 
virtual Co tryLocalBuild ()
 
Co buildDone ()
 
Co resolvedFinished ()
 
HookReply tryBuildHook ()
 
virtual int getChildStatus ()
 
virtual SingleDrvOutputs registerOutputs ()
 
Path openLogFile ()
 
virtual void signRealisation (Realisation &)
 
void closeLogFile ()
 
virtual void closeReadPipes ()
 
virtual void cleanupHookFinally ()
 
virtual void cleanupPreChildKill ()
 
virtual void cleanupPostChildKill ()
 
virtual bool cleanupDecideWhetherDiskFull ()
 
virtual void cleanupPostOutputsRegisteredModeCheck ()
 
virtual void cleanupPostOutputsRegisteredModeNonCheck ()
 
virtual bool isReadDesc (Descriptor fd)
 
void handleChildOutput (Descriptor fd, std::string_view data) override
 
void handleEOF (Descriptor fd) override
 
void flushLine ()
 
std::map< std::string, std::optional< StorePath > > queryPartialDerivationOutputMap ()
 
OutputPathMap queryDerivationOutputMap ()
 
std::pair< bool, SingleDrvOutputscheckPathValidity ()
 
SingleDrvOutputs assertPathValidity ()
 
virtual void killChild ()
 
Co repairClosure ()
 
void started ()
 
Done done (BuildResult::Status status, SingleDrvOutputs builtOutputs={}, std::optional< Error > ex={})
 
void waiteeDone (GoalPtr waitee, ExitCode result) override
 
StorePathSet exportReferences (const StorePathSet &storePaths)
 
JobCategory jobCategory () const override
 Hint for the scheduler, which concurrency limit applies.
 
- Public Member Functions inherited from nix::Goal
Co init_wrapper ()
 
Done amDone (ExitCode result, std::optional< Error > ex={})
 
virtual void cleanup ()
 
BuildResult getBuildResult (const DerivedPath &) const
 
 Goal (Worker &worker, DerivedPath path)
 
void work ()
 
void addWaitee (GoalPtr waitee)
 
void trace (std::string_view s)
 
std::string getName () const
 

Public Attributes

bool useDerivation
 
StorePath drvPath
 
std::shared_ptr< DerivationGoalresolvedDrvGoal
 
OutputsSpec wantedOutputs
 
std::map< std::pair< StorePath, std::string >, StorePathinputDrvOutputs
 
NeedRestartForMoreOutputs needRestart = NeedRestartForMoreOutputs::OutputsUnmodifedDontNeed
 
RetrySubstitution retrySubstitution = RetrySubstitution::NoNeed
 
std::unique_ptr< Derivationdrv
 
std::unique_ptr< ParsedDerivationparsedDrv
 
PathLocks outputLocks
 
StorePathSet inputPaths
 
std::map< std::string, InitialOutputinitialOutputs
 
AutoCloseFD fdLogFile
 
std::shared_ptr< BufferedSinklogFileSink
 
std::shared_ptr< BufferedSinklogSink
 
unsigned long logSize
 
std::list< std::string > logTail
 
std::string currentLogLine
 
size_t currentLogLinePos = 0
 
std::string currentHookLine
 
std::unique_ptr< HookInstance > hook
 
std::optional< DerivationTypederivationType
 
BuildMode buildMode
 
std::unique_ptr< MaintainCount< uint64_t > > mcExpectedBuilds
 
std::unique_ptr< MaintainCount< uint64_t > > mcRunningBuilds
 
std::unique_ptr< Activityact
 
std::unique_ptr< ActivityactLock
 
std::map< ActivityId, ActivitybuilderActivities
 
std::string machineName
 
- Public Attributes inherited from nix::Goal
Workerworker
 
Goals waitees
 
WeakGoals waiters
 
size_t nrFailed = 0
 
size_t nrNoSubstituters = 0
 
size_t nrIncompleteClosure = 0
 
std::string name
 
ExitCode exitCode = ecBusy
 
std::optional< Cotop_co
 
std::optional< Error > ex
 

Additional Inherited Members

- Protected Attributes inherited from nix::Goal
BuildResult buildResult
 

Detailed Description

A goal for building some or all of the outputs of a derivation.

Member Enumeration Documentation

◆ NeedRestartForMoreOutputs

See needRestart; just for that field.

Enumerator
OutputsUnmodifedDontNeed 

The goal state machine is progressing based on the current value of `wantedOutputs. No actions are needed.

OutputsAddedDoNeed 

wantedOutputs has been extended, but the state machine is proceeding according to its old value, so we need to restart.

BuildInProgressWillNotNeed 

The goal state machine has progressed to the point of doing a build, in which case all outputs will be produced, so extensions to wantedOutputs no longer require a restart.

◆ RetrySubstitution

See retrySubstitution; just for that field.

Enumerator
NoNeed 

No issues have yet arose, no need to restart.

YesNeed 

Something failed and there is an incomplete closure. Let's retry substituting.

AlreadyRetried 

We are current or have already retried substitution, and whether or not something goes wrong we will not retry again.

Member Function Documentation

◆ addWantedOutputs()

void nix::DerivationGoal::addWantedOutputs ( const OutputsSpec & outputs)

Add wanted outputs to an already existing derivation goal.

◆ assertPathValidity()

SingleDrvOutputs nix::DerivationGoal::assertPathValidity ( )

Aborts if any output is not valid or corrupt, and otherwise returns a 'SingleDrvOutputs' structure containing all outputs.

◆ checkPathValidity()

std::pair< bool, SingleDrvOutputs > nix::DerivationGoal::checkPathValidity ( )

Update 'initialOutputs' to determine the current status of the outputs of the derivation. Also returns a Boolean denoting whether all outputs are valid and non-corrupt, and a 'SingleDrvOutputs' structure containing the valid outputs.

◆ cleanupHookFinally()

void nix::DerivationGoal::cleanupHookFinally ( )
virtual

Cleanup hooks for buildDone()

◆ closeLogFile()

void nix::DerivationGoal::closeLogFile ( )

Close the log file.

◆ closeReadPipes()

void nix::DerivationGoal::closeReadPipes ( )
virtual

Close the read side of the logger pipe.

◆ handleChildOutput()

void nix::DerivationGoal::handleChildOutput ( Descriptor fd,
std::string_view data )
overridevirtual

Callback used by the worker to write to the log.

Reimplemented from nix::Goal.

◆ handleEOF()

void nix::DerivationGoal::handleEOF ( Descriptor fd)
overridevirtual

Reimplemented from nix::Goal.

◆ init()

Goal::Co nix::DerivationGoal::init ( )
overridevirtual

The states.

Implements nix::Goal.

◆ jobCategory()

JobCategory nix::DerivationGoal::jobCategory ( ) const
inlineoverridevirtual

Hint for the scheduler, which concurrency limit applies.

See also
JobCategory

Implements nix::Goal.

◆ key()

std::string nix::DerivationGoal::key ( )
overridevirtual

Implements nix::Goal.

◆ killChild()

void nix::DerivationGoal::killChild ( )
virtual

Forcibly kill the child process, if any.

◆ openLogFile()

Path nix::DerivationGoal::openLogFile ( )

Open a log file and a pipe to it.

◆ queryPartialDerivationOutputMap()

std::map< std::string, std::optional< StorePath > > nix::DerivationGoal::queryPartialDerivationOutputMap ( )

Wrappers around the corresponding Store methods that first consult the derivation. This is currently needed because when there is no drv file there also is no DB entry.

◆ registerOutputs()

SingleDrvOutputs nix::DerivationGoal::registerOutputs ( )
virtual

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

◆ signRealisation()

virtual void nix::DerivationGoal::signRealisation ( Realisation & )
inlinevirtual

Sign the newly built realisation if the store allows it

◆ timedOut()

void nix::DerivationGoal::timedOut ( Error && ex)
overridevirtual

Callback in case of a timeout. It should wake up its waiters, get rid of any running child processes that are being monitored by the worker (important!), etc.

Implements nix::Goal.

◆ tryBuildHook()

HookReply nix::DerivationGoal::tryBuildHook ( )

Is the build hook willing to perform the build?

◆ waiteeDone()

void nix::DerivationGoal::waiteeDone ( GoalPtr waitee,
ExitCode result )
overridevirtual

Reimplemented from nix::Goal.

Member Data Documentation

◆ actLock

std::unique_ptr<Activity> nix::DerivationGoal::actLock

Activity that denotes waiting for a lock.

◆ derivationType

std::optional<DerivationType> nix::DerivationGoal::derivationType

The sort of derivation we are building.

◆ drv

std::unique_ptr<Derivation> nix::DerivationGoal::drv

The derivation stored at drvPath.

◆ drvPath

StorePath nix::DerivationGoal::drvPath

The path of the derivation.

◆ fdLogFile

AutoCloseFD nix::DerivationGoal::fdLogFile

File descriptor for the log file.

◆ hook

std::unique_ptr<HookInstance> nix::DerivationGoal::hook

The build hook.

◆ inputDrvOutputs

std::map<std::pair<StorePath, std::string>, StorePath> nix::DerivationGoal::inputDrvOutputs

Mapping from input derivations + output names to actual store paths. This is filled in by waiteeDone() as each dependency finishes, before inputsRealised() is reached.

◆ inputPaths

StorePathSet nix::DerivationGoal::inputPaths

All input paths (that is, the union of FS closures of the immediate input paths).

◆ logSize

unsigned long nix::DerivationGoal::logSize

Number of bytes received from the builder's stdout/stderr.

◆ logTail

std::list<std::string> nix::DerivationGoal::logTail

The most recent log lines.

◆ machineName

std::string nix::DerivationGoal::machineName

The remote machine on which we're building.

◆ needRestart

Whether additional wanted outputs have been added.

◆ outputLocks

PathLocks nix::DerivationGoal::outputLocks

The remainder is state held during the build. Locks on (fixed) output paths.

◆ resolvedDrvGoal

std::shared_ptr<DerivationGoal> nix::DerivationGoal::resolvedDrvGoal

The goal for the corresponding resolved derivation

◆ retrySubstitution

RetrySubstitution nix::DerivationGoal::retrySubstitution = RetrySubstitution::NoNeed

Whether to retry substituting the outputs after building the inputs. This is done in case of an incomplete closure.

◆ useDerivation

bool nix::DerivationGoal::useDerivation

Whether to use an on-disk .drv file.

◆ wantedOutputs

OutputsSpec nix::DerivationGoal::wantedOutputs

The specific outputs that we need to build.


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