diff --git a/src/libstore/build/derivation-building-goal.cc b/src/libstore/build/derivation-building-goal.cc index a82f7f928..6e2fa445c 100644 --- a/src/libstore/build/derivation-building-goal.cc +++ b/src/libstore/build/derivation-building-goal.cc @@ -148,6 +148,9 @@ std::string showKnownOutputs(const StoreDirConfig & store, const Derivation & dr return msg; } +static void runPostBuildHook( + const StoreDirConfig & store, Logger & logger, const StorePath & drvPath, const StorePathSet & outputPaths); + /* At least one of the output paths could not be produced using a substitute. So we have to build instead. */ Goal::Co DerivationBuildingGoal::gaveUpOnSubstitution() @@ -810,6 +813,11 @@ Goal::Co DerivationBuildingGoal::tryToBuild() outputLocks.unlock(); co_return done(std::move(ste->first), {}, std::move(ste->second)); } else if (auto * builtOutputs = std::get_if<1>(&res)) { + StorePathSet outputPaths; + for (auto & [_, output] : *builtOutputs) + outputPaths.insert(output.outPath); + runPostBuildHook(worker.store, *logger, drvPath, outputPaths); + /* It is now safe to delete the lock files, since all future lockers will see that the output paths are valid; they will not create new lock files with the same names as the old @@ -823,7 +831,7 @@ Goal::Co DerivationBuildingGoal::tryToBuild() #endif } -void runPostBuildHook( +static void runPostBuildHook( const StoreDirConfig & store, Logger & logger, const StorePath & drvPath, const StorePathSet & outputPaths) { auto hook = settings.postBuildHook; diff --git a/src/libstore/include/nix/store/build/derivation-building-misc.hh b/src/libstore/include/nix/store/build/derivation-building-misc.hh index f9e965104..2b68fa178 100644 --- a/src/libstore/include/nix/store/build/derivation-building-misc.hh +++ b/src/libstore/include/nix/store/build/derivation-building-misc.hh @@ -49,9 +49,6 @@ struct InitialOutput std::optional known; }; -void runPostBuildHook( - const StoreDirConfig & store, Logger & logger, const StorePath & drvPath, const StorePathSet & outputPaths); - /** * Format the known outputs of a derivation for use in error messages. */ diff --git a/src/libstore/include/nix/store/build/derivation-goal.hh b/src/libstore/include/nix/store/build/derivation-goal.hh index 589c3fd58..d9042d136 100644 --- a/src/libstore/include/nix/store/build/derivation-goal.hh +++ b/src/libstore/include/nix/store/build/derivation-goal.hh @@ -14,9 +14,6 @@ namespace nix { using std::map; -/** Used internally */ -void runPostBuildHook(Store & store, Logger & logger, const StorePath & drvPath, const StorePathSet & outputPaths); - /** * A goal for realising a single output of a derivation. Various sorts of * fetching (which will be done by other goal types) is tried, and if none of diff --git a/src/libstore/unix/build/derivation-builder.cc b/src/libstore/unix/build/derivation-builder.cc index 15c99e3c0..51b44719d 100644 --- a/src/libstore/unix/build/derivation-builder.cc +++ b/src/libstore/unix/build/derivation-builder.cc @@ -506,11 +506,6 @@ std::variant, SingleDrvOutputs> Derivation being valid. */ auto builtOutputs = registerOutputs(); - StorePathSet outputPaths; - for (auto & [_, output] : builtOutputs) - outputPaths.insert(output.outPath); - runPostBuildHook(store, *logger, drvPath, outputPaths); - /* Delete unused redirected outputs (when doing hash rewriting). */ for (auto & i : redirectedOutputs) deletePath(store.Store::toRealPath(i.second));