mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-26 07:46:21 +02:00
Merge pull request #4732 from NixOS/4725-always-register-the-realisations
Aways register the realisations
This commit is contained in:
commit
4549d65b4f
3 changed files with 40 additions and 15 deletions
|
@ -736,19 +736,10 @@ std::set<RealisedPath> toRealisedPaths(
|
||||||
output.first);
|
output.first);
|
||||||
auto outputId = DrvOutput{outputHashes.at(output.first), output.first};
|
auto outputId = DrvOutput{outputHashes.at(output.first), output.first};
|
||||||
auto realisation = store->queryRealisation(outputId);
|
auto realisation = store->queryRealisation(outputId);
|
||||||
if (!realisation) {
|
if (!realisation)
|
||||||
// TODO: remove this check once #4725 is fixed
|
|
||||||
// as we’ll have the guaranty that if
|
|
||||||
// `output.second` exists, then the realisation
|
|
||||||
// will be there too
|
|
||||||
if (output.second)
|
|
||||||
res.insert(*output.second);
|
|
||||||
else
|
|
||||||
throw Error("cannot operate on an output of unbuilt content-addresed derivation '%s'", outputId.to_string());
|
throw Error("cannot operate on an output of unbuilt content-addresed derivation '%s'", outputId.to_string());
|
||||||
} else {
|
|
||||||
res.insert(RealisedPath{*realisation});
|
res.insert(RealisedPath{*realisation});
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else {
|
else {
|
||||||
// If ca-derivations isn't enabled, behave as if
|
// If ca-derivations isn't enabled, behave as if
|
||||||
// all the paths are opaque to keep the default
|
// all the paths are opaque to keep the default
|
||||||
|
|
|
@ -1269,12 +1269,23 @@ void DerivationGoal::checkPathValidity()
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
if (settings.isExperimentalFeatureEnabled("ca-derivations")) {
|
if (settings.isExperimentalFeatureEnabled("ca-derivations")) {
|
||||||
if (auto real = worker.store.queryRealisation(
|
auto drvOutput = DrvOutput{initialOutputs.at(i.first).outputHash, i.first};
|
||||||
DrvOutput{initialOutputs.at(i.first).outputHash, i.first})) {
|
if (auto real = worker.store.queryRealisation(drvOutput)) {
|
||||||
info.known = {
|
info.known = {
|
||||||
.path = real->outPath,
|
.path = real->outPath,
|
||||||
.status = PathStatus::Valid,
|
.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,
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,8 @@ sed -i 's/experimental-features .*/& ca-derivations ca-references/' "$NIX_CONF_D
|
||||||
|
|
||||||
rm -rf $TEST_ROOT/binary_cache
|
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 () {
|
buildDrvs () {
|
||||||
nix build --file ./content-addressed.nix -L --no-link "$@"
|
nix build --file ./content-addressed.nix -L --no-link "$@"
|
||||||
|
@ -22,3 +23,25 @@ buildDrvs --post-build-hook ../push-to-store.sh
|
||||||
clearStore
|
clearStore
|
||||||
buildDrvs --substitute --substituters $REMOTE_STORE --no-require-sigs -j0
|
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
|
||||||
|
# There's no easy way to check whether a realisation is present on the local
|
||||||
|
# store − short of manually querying the db, but the build environment doesn't
|
||||||
|
# have the sqlite binary − so we instead push things again, and check that the
|
||||||
|
# realisations have correctly been pushed to the remote store
|
||||||
|
nix copy --to "$REMOTE_STORE" --file ../simple.nix
|
||||||
|
if [[ -z "$(ls "$REMOTE_STORE_DIR/realisations")" ]]; then
|
||||||
|
echo "Realisations not rebuilt"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
Loading…
Reference in a new issue