Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: NixOS/nix
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 33a917a6a496
Choose a base ref
...
head repository: NixOS/nix
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 9161e02039e6
Choose a head ref
  • 2 commits
  • 2 files changed
  • 1 contributor

Commits on Apr 22, 2021

  1. Copy the full SHA
    b171107 View commit details
  2. Copy the full SHA
    9161e02 View commit details
Showing with 32 additions and 3 deletions.
  1. +13 −2 src/libstore/build/derivation-goal.cc
  2. +19 −1 tests/ca/substitute.sh
15 changes: 13 additions & 2 deletions src/libstore/build/derivation-goal.cc
Original file line number Diff line number Diff line change
@@ -1269,12 +1269,23 @@ void DerivationGoal::checkPathValidity()
};
}
if (settings.isExperimentalFeatureEnabled("ca-derivations")) {
if (auto real = worker.store.queryRealisation(
DrvOutput{initialOutputs.at(i.first).outputHash, i.first})) {
auto drvOutput = DrvOutput{initialOutputs.at(i.first).outputHash, i.first};
if (auto real = worker.store.queryRealisation(drvOutput)) {
info.known = {
.path = real->outPath,
.status = PathStatus::Valid,
};
} else if (info.known && info.known->status == PathStatus::Valid) {
// We know the output because it' a static output of the
// derivation, and the output path is valid, but we don't have
// its realisation stored (probably because it has been built
// without the `ca-derivations` experimental flag)
worker.store.registerDrvOutput(
Realisation{
drvOutput,
info.known->path,
}
);
}
}
}
20 changes: 19 additions & 1 deletion tests/ca/substitute.sh
Original file line number Diff line number Diff line change
@@ -8,7 +8,8 @@ sed -i 's/experimental-features .*/& ca-derivations ca-references/' "$NIX_CONF_D

rm -rf $TEST_ROOT/binary_cache

export REMOTE_STORE=file://$TEST_ROOT/binary_cache
export REMOTE_STORE_DIR=$TEST_ROOT/binary_cache
export REMOTE_STORE=file://$REMOTE_STORE_DIR

buildDrvs () {
nix build --file ./content-addressed.nix -L --no-link "$@"
@@ -22,3 +23,20 @@ buildDrvs --post-build-hook ../push-to-store.sh
clearStore
buildDrvs --substitute --substituters $REMOTE_STORE --no-require-sigs -j0

# Same thing, but
# 1. With non-ca derivations
# 2. Erasing the realisations on the remote store
#
# Even in that case, realising the derivations should still produce the right
# realisations on the local store
#
# Regression test for #4725
clearStore
nix build --file ../simple.nix -L --no-link --post-build-hook ../push-to-store.sh
clearStore
rm -r "$REMOTE_STORE_DIR/realisations"
nix build --file ../simple.nix -L --no-link --substitute --substituters "$REMOTE_STORE" --no-require-sigs -j0
if [[ $(sqlite3 "$NIX_STATE_DIR/db/db.sqlite" 'select count(*) from Realisations') -eq 0 ]]; then
echo "Realisations not rebuilt"
exit 1
fi