From a22755721b51949dbf03bc1eb156d6f37dc10bac Mon Sep 17 00:00:00 2001 From: regnat Date: Wed, 19 May 2021 14:51:34 +0200 Subject: [PATCH] Recursively substitute the realisations Make sure that whenever we substitute a realisation, we also substitute its entire closure --- src/libstore/build/drv-output-substitution-goal.cc | 6 ++++++ src/libutil/comparator.hh | 4 +++- tests/ca/substitute.sh | 8 ++++++-- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/libstore/build/drv-output-substitution-goal.cc b/src/libstore/build/drv-output-substitution-goal.cc index a5ac4c49d..1703e845d 100644 --- a/src/libstore/build/drv-output-substitution-goal.cc +++ b/src/libstore/build/drv-output-substitution-goal.cc @@ -53,6 +53,12 @@ void DrvOutputSubstitutionGoal::tryNext() return; } + for (const auto & [drvOutputDep, _] : outputInfo->dependentRealisations) { + if (drvOutputDep != id) { + addWaitee(worker.makeDrvOutputSubstitutionGoal(drvOutputDep)); + } + } + addWaitee(worker.makePathSubstitutionGoal(outputInfo->outPath)); if (waitees.empty()) outPathValid(); diff --git a/src/libutil/comparator.hh b/src/libutil/comparator.hh index 0315dc506..eecd5b819 100644 --- a/src/libutil/comparator.hh +++ b/src/libutil/comparator.hh @@ -25,6 +25,8 @@ } #define GENERATE_EQUAL(args...) GENERATE_ONE_CMP(==, args) #define GENERATE_LEQ(args...) GENERATE_ONE_CMP(<, args) +#define GENERATE_NEQ(args...) GENERATE_ONE_CMP(!=, args) #define GENERATE_CMP(args...) \ GENERATE_EQUAL(args) \ - GENERATE_LEQ(args) + GENERATE_LEQ(args) \ + GENERATE_NEQ(args) diff --git a/tests/ca/substitute.sh b/tests/ca/substitute.sh index dfc4ea68e..c80feaacf 100644 --- a/tests/ca/substitute.sh +++ b/tests/ca/substitute.sh @@ -17,11 +17,15 @@ buildDrvs () { # Populate the remote cache clearStore -buildDrvs --post-build-hook ../push-to-store.sh +nix copy --to $REMOTE_STORE --file ./content-addressed.nix # Restart the build on an empty store, ensuring that we don't build clearStore -buildDrvs --substitute --substituters $REMOTE_STORE --no-require-sigs -j0 +buildDrvs --substitute --substituters $REMOTE_STORE --no-require-sigs -j0 transitivelyDependentCA +# Check that the thing we’ve just substituted has its realisation stored +nix realisation info --file ./content-addressed.nix transitivelyDependentCA +# Check that its dependencies have it too +nix realisation info --file ./content-addressed.nix dependentCA rootCA # Same thing, but # 1. With non-ca derivations