From 608434722b1f6a25bd4dba6b28e7f7e516c687fb Mon Sep 17 00:00:00 2001
From: regnat <rg@regnat.ovh>
Date: Mon, 21 Jun 2021 15:47:47 +0200
Subject: [PATCH] Only symlink the requested outputs in `nix build`

Fix #4925
---
 src/nix/build.cc | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/src/nix/build.cc b/src/nix/build.cc
index d924fe553..15923ebc3 100644
--- a/src/nix/build.cc
+++ b/src/nix/build.cc
@@ -69,8 +69,7 @@ struct CmdBuild : InstallablesCommand, MixDryRun, MixJSON, MixProfile
                             store2->addPermRoot(bo.path, absPath(symlink));
                         },
                         [&](BuiltPath::Built bfd) {
-                            auto builtOutputs = store->queryDerivationOutputMap(bfd.drvPath);
-                            for (auto & output : builtOutputs) {
+                            for (auto & output : bfd.outputs) {
                                 std::string symlink = outLink;
                                 if (i) symlink += fmt("-%d", i);
                                 if (output.first != "out") symlink += fmt("-%s", output.first);
-- 
GitLab