Skip to content

Commit 0b37ab6

Browse files
committed
print builder name when builder is local
1 parent 2e262c6 commit 0b37ab6

File tree

3 files changed

+34
-14
lines changed

3 files changed

+34
-14
lines changed

src/libstore/build/derivation-building-goal.cc

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -263,23 +263,29 @@ Goal::Co DerivationBuildingGoal::tryToBuild()
263263
: buildMode == bmCheck ? "checking outputs of '%s'"
264264
: "building '%s'",
265265
worker.store.printStorePath(drvPath));
266+
267+
std::string builderName;
266268
#ifndef _WIN32 // TODO enable build hook on Windows
267-
if (hook)
268-
msg += fmt(" on '%s'", hook->machineName);
269+
if (hook) {
270+
builderName = fmt("remote builder: %s", hook->machineName);
271+
} else if (builder) {
272+
auto maybeUID = builder->getBuilderUID();
273+
if (maybeUID)
274+
builderName = fmt("localhost builder with uid: %s", std::to_string(*maybeUID));
275+
else
276+
builderName = "";
277+
} else {
278+
builderName = "";
279+
}
280+
#else
281+
builderName = "";
269282
#endif
283+
if (builderName != "")
284+
msg += fmt(" on '%s'", builderName);
285+
270286
act = std::make_unique<Activity>(
271-
*logger,
272-
lvlInfo,
273-
actBuild,
274-
msg,
275-
Logger::Fields{
276-
worker.store.printStorePath(drvPath),
277-
#ifndef _WIN32 // TODO enable build hook on Windows
278-
hook ? hook->machineName :
279-
#endif
280-
"",
281-
1,
282-
1});
287+
*logger, lvlInfo, actBuild, msg, Logger::Fields{worker.store.printStorePath(drvPath), builderName, 1, 1});
288+
283289
mcRunningBuilds = std::make_unique<MaintainCount<uint64_t>>(worker.runningBuilds);
284290
worker.updateProgress();
285291
};

src/libstore/include/nix/store/build/derivation-builder.hh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,13 @@ struct DerivationBuilder : RestrictionContext
180180
* killed.
181181
*/
182182
virtual bool killChild() = 0;
183+
184+
/**
185+
* Get the builder UID.
186+
*
187+
* @returns the builder UID if run on localhost (e.g. if it exists).
188+
*/
189+
virtual std::optional<uid_t> getBuilderUID() = 0;
183190
};
184191

185192
struct ExternalBuilder

src/libstore/unix/build/derivation-builder.cc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,8 @@ class DerivationBuilderImpl : public DerivationBuilder, public DerivationBuilder
415415

416416
bool killChild() override;
417417

418+
std::optional<uid_t> getBuilderUID() override;
419+
418420
private:
419421

420422
bool decideWhetherDiskFull();
@@ -494,6 +496,11 @@ bool DerivationBuilderImpl::killChild()
494496
return ret;
495497
}
496498

499+
std::optional<uid_t> DerivationBuilderImpl::getBuilderUID()
500+
{
501+
return (buildUser) ? std::optional<uid_t>(buildUser->getUID()) : std::nullopt;
502+
}
503+
497504
SingleDrvOutputs DerivationBuilderImpl::unprepareBuild()
498505
{
499506
/* Since we got an EOF on the logger pipe, the builder is presumed

0 commit comments

Comments
 (0)