From 1a4c9ba50bb36ab5d18f47b0d00052d274ed824f Mon Sep 17 00:00:00 2001 From: regnat Date: Wed, 3 Nov 2021 10:54:17 +0100 Subject: [PATCH] =?UTF-8?q?Fix=20`nix=20repl`=E2=80=99s=20building=20of=20?= =?UTF-8?q?CA=20derivations?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When running a `:b` command in the repl, after building the derivations query the store for its outputs rather than just assuming that they are known in the derivation itself (which isn’t true for CA derivations) Fix #5328 --- src/nix/repl.cc | 4 ++-- tests/ca/repl.sh | 5 +++++ tests/local.mk | 2 +- tests/repl.sh | 4 +++- 4 files changed, 11 insertions(+), 4 deletions(-) create mode 100644 tests/ca/repl.sh diff --git a/src/nix/repl.cc b/src/nix/repl.cc index 9c0d22438..bc31cf1d4 100644 --- a/src/nix/repl.cc +++ b/src/nix/repl.cc @@ -504,8 +504,8 @@ bool NixRepl::processLine(string line) state->store->buildPaths({DerivedPath::Built{drvPath}}); auto drv = state->store->readDerivation(drvPath); logger->cout("\nThis derivation produced the following outputs:"); - for (auto & i : drv.outputsAndOptPaths(*state->store)) - logger->cout(" %s -> %s", i.first, state->store->printStorePath(*i.second.second)); + for (auto & [outputName, outputPath] : state->store->queryDerivationOutputMap(drvPath)) + logger->cout(" %s -> %s", outputName, state->store->printStorePath(outputPath)); } else if (command == ":i") { runNix("nix-env", {"-i", drvPathRaw}); } else { diff --git a/tests/ca/repl.sh b/tests/ca/repl.sh new file mode 100644 index 000000000..3808c7cb2 --- /dev/null +++ b/tests/ca/repl.sh @@ -0,0 +1,5 @@ +source common.sh + +export NIX_TESTS_CA_BY_DEFAULT=1 + +cd .. && source repl.sh diff --git a/tests/local.mk b/tests/local.mk index 8d454ee19..b63a12d96 100644 --- a/tests/local.mk +++ b/tests/local.mk @@ -48,7 +48,7 @@ nix_tests = \ flakes.sh \ build.sh \ compute-levels.sh \ - repl.sh \ + repl.sh ca/repl.sh \ ca/build.sh \ ca/build-with-garbage-path.sh \ ca/duplicate-realisation-in-closure.sh \ diff --git a/tests/repl.sh b/tests/repl.sh index 4e3059517..d360821f2 100644 --- a/tests/repl.sh +++ b/tests/repl.sh @@ -7,7 +7,9 @@ simple = import ./simple.nix testRepl () { local nixArgs=("$@") - local outPath=$(nix repl "${nixArgs[@]}" <<< "$replCmds" |& + local replOutput="$(nix repl "${nixArgs[@]}" <<< "$replCmds")" + echo "$replOutput" + local outPath=$(echo "$replOutput" |& grep -o -E "$NIX_STORE_DIR/\w*-simple") nix path-info "${nixArgs[@]}" "$outPath" }