![]() |
Nix 2.36.0
Nix, the purely functional package manager; unstable internal interfaces
|
#include <derivation-trampoline-goal.hh>
Public Member Functions | |
| DerivationTrampolineGoal (ref< const SingleDerivedPath > drvReq, const OutputsSpec &wantedOutputs, Worker &worker, BuildMode buildMode=bmNormal) | |
| DerivationTrampolineGoal (const StorePath &drvPath, const OutputsSpec &wantedOutputs, const Derivation &drv, Worker &worker, BuildMode buildMode=bmNormal) | |
| std::string | key () override |
| JobCategory | jobCategory () const override |
| Hint for the scheduler, which concurrency limit applies. | |
| Public Member Functions inherited from nix::Goal | |
| virtual void | cleanup () |
| Goal (Worker &worker, Co< ExitCode > init) | |
| void | work () |
| void | handleChildOutput (Descriptor fd, std::string_view data) |
| void | handleEOF (Descriptor fd) |
| void | timedOut (TimedOut &&ex) |
| void | trace (std::string_view s) |
| std::string | getName () const |
| std::string_view | keyCached () & |
Public Attributes | |
| ref< const SingleDerivedPath > | drvReq |
| OutputsSpec | wantedOutputs |
| Public Attributes inherited from nix::Goal | |
| Worker & | worker |
| WeakGoals | waiters |
| size_t | nrFailed = 0 |
| size_t | nrNoSubstituters = 0 |
| std::string | name |
| std::optional< ExitCode > | exitCode |
| BuildResult | buildResult |
| bool | preserveFailure = false |
Additional Inherited Members | |
| Public Types inherited from nix::Goal | |
| enum | ExitCode { ecSuccess , ecFailed , ecNoSubstituters } |
| using | ChildEvent = std::variant<ChildOutput, ChildEOF, std::unique_ptr<TimedOut>> |
| template<typename T> | |
| using | HandleType = std::coroutine_handle<AwaitableFrame<T>> |
| using | HandleTypeBase = std::coroutine_handle<AwaitableFrameBase> |
| Protected Member Functions inherited from nix::Goal | |
| Co< void > | await (Goals waitees) |
| Co< void > | waitForAWhile () |
| Co< void > | waitUntilWoken () |
| Co< void > | waitForBuildSlot () |
| Co< void > | yield () |
| Protected Attributes inherited from nix::Goal | |
| std::optional< CoBase > | top_co |
| std::optional< ExitCode > | finalExitCode |
This is the "outermost" goal type relating to derivations — by that we mean that this one calls all the others for a given derivation.
This is a purely "administrative" goal type, which doesn't do any "real work". See DerivationGoal for what we mean by such an administrative goal.
It exists to solve two problems:
We want to build a derivation we don't yet have.
Traditionally, that simply means we try to substitute the missing derivation; simple enough. However, with (currently experimental) dynamic derivations, derivations themselves can be the outputs of other derivations. That means the general case is that a DerivationTrampolineGoal needs to create another DerivationTrampolineGoal goal to realize the derivation it needs. That goal in turn might need to create a third DerivationTrampolineGoal, the induction down to a statically known derivation as the base case is arbitrary deep.
Only a subset of outputs is needed, but such subsets are discovered dynamically.
Consider derivations:
With the current Worker architecture, we're first discover needing A^y,z and then discover needing A^x,y. Of course, we don't want to download A^y twice, either.
The way we handle sharing work for A^y is to have DerivationGoal just handle a single output, and do slightly more work (though it is just an "administrative" goal too), and DerivationTrampolineGoal handle sets of goals, but have it (once the derivation itself has been gotten) just create DerivationGoals.
That means it is fine to create man DerivationTrampolineGoal with overlapping sets of outputs, because all the "real work" will be coordinated via DerivationGoals, and sharing will be discovered.
Both these problems can be solved by having just a more powerful DerivationGoal, but that makes DerivationGoal more complex. However the more complex DerivationGoal has these downsides:
(1) is not so bad, but (2) is quite scary, and has been a source of bugs in the past. By splitting out DerivationTrampolineGoal, we crucially avoid a need for (2), letting goal sharing rather than ad-hoc retry mechanisms accomplish the deduplication we need. Solving (1) is just a by-product and extra bonus of creating DerivationTrampolineGoal.
If we already have the derivation (e.g. if the evaluator has created the derivation locally and then instructed the store to build it), we can skip the derivation-getting goal entirely as a small optimization.
|
inlineoverridevirtual |
|
overridevirtual |
Used for comparisons. The order matters a bit for scheduling. We want:
Also, ensure that derivations get processed in order of their name, i.e. a derivation named "aardvark" always comes before "baboon".
Implements nix::Goal.
| ref<const SingleDerivedPath> nix::DerivationTrampolineGoal::drvReq |
How to obtain a store path of the derivation to build.
| OutputsSpec nix::DerivationTrampolineGoal::wantedOutputs |
The specific outputs that we need to build.