Skip to content

Commit 1a4c9ba

Browse files
committed
Fix nix repl’s building of CA derivations
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 NixOS#5328
1 parent 886ad00 commit 1a4c9ba

File tree

4 files changed

+11
-4
lines changed

4 files changed

+11
-4
lines changed

src/nix/repl.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -504,8 +504,8 @@ bool NixRepl::processLine(string line)
504504
state->store->buildPaths({DerivedPath::Built{drvPath}});
505505
auto drv = state->store->readDerivation(drvPath);
506506
logger->cout("\nThis derivation produced the following outputs:");
507-
for (auto & i : drv.outputsAndOptPaths(*state->store))
508-
logger->cout(" %s -> %s", i.first, state->store->printStorePath(*i.second.second));
507+
for (auto & [outputName, outputPath] : state->store->queryDerivationOutputMap(drvPath))
508+
logger->cout(" %s -> %s", outputName, state->store->printStorePath(outputPath));
509509
} else if (command == ":i") {
510510
runNix("nix-env", {"-i", drvPathRaw});
511511
} else {

tests/ca/repl.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
source common.sh
2+
3+
export NIX_TESTS_CA_BY_DEFAULT=1
4+
5+
cd .. && source repl.sh

tests/local.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ nix_tests = \
4848
flakes.sh \
4949
build.sh \
5050
compute-levels.sh \
51-
repl.sh \
51+
repl.sh ca/repl.sh \
5252
ca/build.sh \
5353
ca/build-with-garbage-path.sh \
5454
ca/duplicate-realisation-in-closure.sh \

tests/repl.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ simple = import ./simple.nix
77

88
testRepl () {
99
local nixArgs=("$@")
10-
local outPath=$(nix repl "${nixArgs[@]}" <<< "$replCmds" |&
10+
local replOutput="$(nix repl "${nixArgs[@]}" <<< "$replCmds")"
11+
echo "$replOutput"
12+
local outPath=$(echo "$replOutput" |&
1113
grep -o -E "$NIX_STORE_DIR/\w*-simple")
1214
nix path-info "${nixArgs[@]}" "$outPath"
1315
}

0 commit comments

Comments
 (0)