Skip to content

Commit 6c8f5ef

Browse files
authored
Merge pull request #13802 from obsidiansystems/post-build-hook-later
Move `runPostBuildHook` out of `DerivationBuilder`
2 parents 193ad73 + 0250d50 commit 6c8f5ef

File tree

4 files changed

+9
-12
lines changed

4 files changed

+9
-12
lines changed

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,9 @@ std::string showKnownOutputs(const StoreDirConfig & store, const Derivation & dr
148148
return msg;
149149
}
150150

151+
static void runPostBuildHook(
152+
const StoreDirConfig & store, Logger & logger, const StorePath & drvPath, const StorePathSet & outputPaths);
153+
151154
/* At least one of the output paths could not be
152155
produced using a substitute. So we have to build instead. */
153156
Goal::Co DerivationBuildingGoal::gaveUpOnSubstitution()
@@ -811,6 +814,11 @@ Goal::Co DerivationBuildingGoal::tryToBuild()
811814
outputLocks.unlock();
812815
co_return done(std::move(ste->first), {}, std::move(ste->second));
813816
} else if (auto * builtOutputs = std::get_if<1>(&res)) {
817+
StorePathSet outputPaths;
818+
for (auto & [_, output] : *builtOutputs)
819+
outputPaths.insert(output.outPath);
820+
runPostBuildHook(worker.store, *logger, drvPath, outputPaths);
821+
814822
/* It is now safe to delete the lock files, since all future
815823
lockers will see that the output paths are valid; they will
816824
not create new lock files with the same names as the old
@@ -824,7 +832,7 @@ Goal::Co DerivationBuildingGoal::tryToBuild()
824832
#endif
825833
}
826834

827-
void runPostBuildHook(
835+
static void runPostBuildHook(
828836
const StoreDirConfig & store, Logger & logger, const StorePath & drvPath, const StorePathSet & outputPaths)
829837
{
830838
auto hook = settings.postBuildHook;

src/libstore/include/nix/store/build/derivation-building-misc.hh

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,6 @@ struct InitialOutput
4949
std::optional<InitialOutputStatus> known;
5050
};
5151

52-
void runPostBuildHook(
53-
const StoreDirConfig & store, Logger & logger, const StorePath & drvPath, const StorePathSet & outputPaths);
54-
5552
/**
5653
* Format the known outputs of a derivation for use in error messages.
5754
*/

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@ namespace nix {
1414

1515
using std::map;
1616

17-
/** Used internally */
18-
void runPostBuildHook(Store & store, Logger & logger, const StorePath & drvPath, const StorePathSet & outputPaths);
19-
2017
/**
2118
* A goal for realising a single output of a derivation. Various sorts of
2219
* fetching (which will be done by other goal types) is tried, and if none of

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -506,11 +506,6 @@ std::variant<std::pair<BuildResult::Status, Error>, SingleDrvOutputs> Derivation
506506
being valid. */
507507
auto builtOutputs = registerOutputs();
508508

509-
StorePathSet outputPaths;
510-
for (auto & [_, output] : builtOutputs)
511-
outputPaths.insert(output.outPath);
512-
runPostBuildHook(store, *logger, drvPath, outputPaths);
513-
514509
/* Delete unused redirected outputs (when doing hash rewriting). */
515510
for (auto & i : redirectedOutputs)
516511
deletePath(store.Store::toRealPath(i.second));

0 commit comments

Comments
 (0)