1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-29 13:41:00 +01:00

Add lazy evaluation for experimental feature reasons

Wrap fmt() calls in lambdas to defer string formatting until the
feature check fails. This avoids unnecessary string formatting in
the common case where the feature is enabled.

Addresses performance concern raised by xokdvium in PR review.
This commit is contained in:
Robert Hensing 2025-10-14 16:49:59 +02:00
parent 39c4665488
commit 1b96a704d3
4 changed files with 23 additions and 6 deletions

View file

@ -86,9 +86,9 @@ void drvRequireExperiment(const SingleDerivedPath & drv, const ExperimentalFeatu
// plain drv path; no experimental features required.
},
[&](const SingleDerivedPath::Built & b) {
xpSettings.require(
Xp::DynamicDerivations,
fmt("building output '%s' of '%s'", b.output, b.drvPath->getBaseStorePath().to_string()));
xpSettings.require(Xp::DynamicDerivations, [&] {
return fmt("building output '%s' of '%s'", b.output, b.drvPath->getBaseStorePath().to_string());
});
},
},
drv.raw());