From 08089fdd3284fcb27bcec347d6bf88ec2a79a8a0 Mon Sep 17 00:00:00 2001 From: Tom Bereknyei Date: Sun, 11 Jun 2023 13:33:38 -0400 Subject: [PATCH 1/2] fix: Do not apply default installables when using --stdin --- src/libcmd/installables.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libcmd/installables.cc b/src/libcmd/installables.cc index a2b882355..684d76a57 100644 --- a/src/libcmd/installables.cc +++ b/src/libcmd/installables.cc @@ -730,9 +730,9 @@ void RawInstallablesCommand::run(ref store) while (std::cin >> word) { rawInstallables.emplace_back(std::move(word)); } + } else { + applyDefaultInstallables(rawInstallables); } - - applyDefaultInstallables(rawInstallables); run(store, std::move(rawInstallables)); } From 0e3849dc650250e36fb69c197a8a1fffe4f7d480 Mon Sep 17 00:00:00 2001 From: Tom Bereknyei Date: Mon, 12 Jun 2023 08:40:17 -0400 Subject: [PATCH 2/2] test: add test for non-defaulting for stding installable input --- src/libcmd/installables.cc | 2 +- tests/build.sh | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/libcmd/installables.cc b/src/libcmd/installables.cc index 684d76a57..10b077fb5 100644 --- a/src/libcmd/installables.cc +++ b/src/libcmd/installables.cc @@ -701,7 +701,7 @@ RawInstallablesCommand::RawInstallablesCommand() { addFlag({ .longName = "stdin", - .description = "Read installables from the standard input.", + .description = "Read installables from the standard input. No default installable applied.", .handler = {&readFromStdIn, true} }); diff --git a/tests/build.sh b/tests/build.sh index 697aff0f9..8ae20f0df 100644 --- a/tests/build.sh +++ b/tests/build.sh @@ -129,3 +129,7 @@ nix build --impure -f multiple-outputs.nix --json e --no-link | jq --exit-status (.drvPath | match(".*multiple-outputs-e.drv")) and (.outputs | keys == ["a_a", "b"])) ' + +# Make sure that `--stdin` works and does not apply any defaults +printf "" | nix build --no-link --stdin --json | jq --exit-status '. == []' +printf "%s\n" "$drv^*" | nix build --no-link --stdin --json | jq --exit-status '.[0]|has("drvPath")'