1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-28 17:51:15 +02:00

Merge pull request #12692 from obsidiansystems/small-derivation-goal-cleanups

Small derivation goal cleanups
This commit is contained in:
Jörg Thalheim 2025-03-19 23:30:23 +01:00 committed by GitHub
commit c97f779dbb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 19 additions and 17 deletions

View file

@ -533,9 +533,6 @@ Goal::Co DerivationGoal::gaveUpOnSubstitution()
debug("added input paths %s", worker.store.showPaths(inputPaths)); debug("added input paths %s", worker.store.showPaths(inputPaths));
/* What type of derivation are we building? */
derivationType = drv->type();
/* Okay, try to build. Note that here we don't wait for a build /* Okay, try to build. Note that here we don't wait for a build
slot to become available, since we don't need one if there is a slot to become available, since we don't need one if there is a
build hook. */ build hook. */
@ -597,16 +594,18 @@ Goal::Co DerivationGoal::tryToBuild()
} }
} }
if (!outputLocks.lockPaths(lockFiles, "", false)) { if (!outputLocks.lockPaths(lockFiles, "", false))
if (!actLock) {
actLock = std::make_unique<Activity>(*logger, lvlWarn, actBuildWaiting, Activity act(*logger, lvlWarn, actBuildWaiting,
fmt("waiting for lock on %s", Magenta(showPaths(lockFiles)))); fmt("waiting for lock on %s", Magenta(showPaths(lockFiles))));
worker.waitForAWhile(shared_from_this());
co_await Suspend{};
co_return tryToBuild();
}
actLock.reset(); /* Wait then try locking again, repeat until success (returned
boolean is true). */
do {
worker.waitForAWhile(shared_from_this());
co_await Suspend{};
} while (!outputLocks.lockPaths(lockFiles, "", false));
}
/* Now check again whether the outputs are valid. This is because /* Now check again whether the outputs are valid. This is because
another process may have started building in parallel. After another process may have started building in parallel. After

View file

@ -198,11 +198,6 @@ struct DerivationGoal : public Goal
std::unique_ptr<HookInstance> hook; std::unique_ptr<HookInstance> hook;
#endif #endif
/**
* The sort of derivation we are building.
*/
std::optional<DerivationType> derivationType;
BuildMode buildMode; BuildMode buildMode;
std::unique_ptr<MaintainCount<uint64_t>> mcExpectedBuilds, mcRunningBuilds; std::unique_ptr<MaintainCount<uint64_t>> mcExpectedBuilds, mcRunningBuilds;

View file

@ -150,6 +150,13 @@ struct LocalDerivationGoal : DerivationGoal, RestrictionContext
*/ */
std::shared_ptr<AutoDelete> autoDelChroot; std::shared_ptr<AutoDelete> autoDelChroot;
/**
* The sort of derivation we are building.
*
* Just a cached value, can be recomputed from `drv`.
*/
std::optional<DerivationType> derivationType;
/** /**
* Stuff we need to pass to initChild(). * Stuff we need to pass to initChild().
*/ */
@ -478,7 +485,8 @@ Goal::Co LocalDerivationGoal::tryLocalBuild()
co_return tryToBuild(); co_return tryToBuild();
} }
assert(derivationType); /* Cache this */
derivationType = drv->type();
/* Are we doing a chroot build? */ /* Are we doing a chroot build? */
{ {