From c29fffeaaad8a3642acaf78fed4414cae30baf7d Mon Sep 17 00:00:00 2001 From: Robert Hensing Date: Sun, 18 Oct 2020 14:21:53 +0200 Subject: [PATCH 1/3] DerivationGoal: only retry if output closure incomplete is only problem (cherry picked from commit bd9eb5c743faf1b3c33f4e1c2ccf317977d4be9d) --- src/libstore/build.cc | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/libstore/build.cc b/src/libstore/build.cc index 4ba9a5385c0..d09db82fcc9 100644 --- a/src/libstore/build.cc +++ b/src/libstore/build.cc @@ -1222,8 +1222,13 @@ void DerivationGoal::outputsSubstituted() /* If the substitutes form an incomplete closure, then we should build the dependencies of this derivation, but after that, we - can still use the substitutes for this derivation itself. */ - if (nrIncompleteClosure > 0) retrySubstitution = true; + can still use the substitutes for this derivation itself. + + If the nrIncompleteClosure != nrFailed, we have another issue as well. + In particular, it may be the case that the hole in the closure is + an output of the current derivation, which causes a loop if retried. + */ + if (nrIncompleteClosure > 0 && nrIncompleteClosure == nrFailed) retrySubstitution = true; nrFailed = nrNoSubstituters = nrIncompleteClosure = 0; From e90530e491278169b501e53ce6773e253b45e15e Mon Sep 17 00:00:00 2001 From: Robert Hensing Date: Sun, 18 Oct 2020 00:43:52 +0200 Subject: [PATCH 2/3] Tests for #3964 (cherry picked from commit ea8d32020e1e24576cf5e8ff1a835f149dbd81c3) --- tests/binary-cache.sh | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/tests/binary-cache.sh b/tests/binary-cache.sh index eb58ae7c12a..7fc6a6fccda 100644 --- a/tests/binary-cache.sh +++ b/tests/binary-cache.sh @@ -168,3 +168,34 @@ clearCacheCache nix-store -r $outPath --substituters "file://$cacheDir2 file://$cacheDir" --trusted-public-keys "$publicKey" fi # HAVE_LIBSODIUM + +# Test against issue https://github.com/NixOS/nix/issues/3964 +# +expr=' + with import ./config.nix; + mkDerivation { + name = "multi-output"; + buildCommand = "mkdir -p $out; echo foo > $doc; echo $doc > $out/docref"; + outputs = ["out" "doc"]; + } +' +outPath=$(nix-build --no-out-link -E "$expr") +docPath=$(nix-store -q --references $outPath) + +# $ nix-store -q --tree $outPath +# ...-multi-output +# +---...-multi-output-doc + +nix copy --to "file://$cacheDir" $outPath + +hashpart() { + basename "$1" | cut -c1-32 +} + +# break the closure of out by removing doc +rm $cacheDir/$(hashpart $docPath).narinfo + +nix-store --delete $outPath $docPath +# -vvv is the level that logs during the loop +timeout 60 nix-build -E "$expr" --option substituters "file://$cacheDir" \ + --option trusted-binary-caches "file://$cacheDir" --no-require-sigs From 8388e2ea48f340e940005aa7ffbc94fe7681c766 Mon Sep 17 00:00:00 2001 From: Robert Hensing Date: Tue, 22 Dec 2020 11:57:31 +0100 Subject: [PATCH 3/3] Revert "Tests for #3964" This reverts commit e90530e491278169b501e53ce6773e253b45e15e. It appears that this backported test relies on new functionality. The error is: + nix copy --to file:///build/nix-test/binary-cache /build/nix-test/store/dckdy2xp7sn8qvyx8axxjq7clnxddri1-multi-output warning: you don't have Internet access; disabling some network-dependent features error: uploading to 'file:///build/nix-test/binary-cache/nar/0hpfhrig9h6fvbjmiwsb7zkaxr19vr2w048y4xb3nrs36bagf92n.nar.xz' is not supported --- tests/binary-cache.sh | 31 ------------------------------- 1 file changed, 31 deletions(-) diff --git a/tests/binary-cache.sh b/tests/binary-cache.sh index 7fc6a6fccda..eb58ae7c12a 100644 --- a/tests/binary-cache.sh +++ b/tests/binary-cache.sh @@ -168,34 +168,3 @@ clearCacheCache nix-store -r $outPath --substituters "file://$cacheDir2 file://$cacheDir" --trusted-public-keys "$publicKey" fi # HAVE_LIBSODIUM - -# Test against issue https://github.com/NixOS/nix/issues/3964 -# -expr=' - with import ./config.nix; - mkDerivation { - name = "multi-output"; - buildCommand = "mkdir -p $out; echo foo > $doc; echo $doc > $out/docref"; - outputs = ["out" "doc"]; - } -' -outPath=$(nix-build --no-out-link -E "$expr") -docPath=$(nix-store -q --references $outPath) - -# $ nix-store -q --tree $outPath -# ...-multi-output -# +---...-multi-output-doc - -nix copy --to "file://$cacheDir" $outPath - -hashpart() { - basename "$1" | cut -c1-32 -} - -# break the closure of out by removing doc -rm $cacheDir/$(hashpart $docPath).narinfo - -nix-store --delete $outPath $docPath -# -vvv is the level that logs during the loop -timeout 60 nix-build -E "$expr" --option substituters "file://$cacheDir" \ - --option trusted-binary-caches "file://$cacheDir" --no-require-sigs