aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2020-07-15 19:50:32 +0200
committerEelco Dolstra <edolstra@gmail.com>2020-07-15 19:50:32 +0200
commite3c2b0023774eed05657ca1dbb469a85bd294d23 (patch)
tree6351278630af27b7965410b63775700e1caac420 /src
parent298ff6af8f38cefe148cc049b136b665245d6c49 (diff)
Make InstallableStorePath behave consistently with InstallableValue
That is, the commands 'nix path-info nixpkgs#hello' and 'nix path-info /nix/store/00ls0qi49qkqpqblmvz5s1ajl3gc63lr-hello-2.10.drv' now do the same thing (i.e. build the derivation and operate on the output store path, rather than the .drv path).
Diffstat (limited to 'src')
-rw-r--r--src/nix/installables.cc27
1 files changed, 18 insertions, 9 deletions
diff --git a/src/nix/installables.cc b/src/nix/installables.cc
index c97a0bdcf..415358970 100644
--- a/src/nix/installables.cc
+++ b/src/nix/installables.cc
@@ -296,15 +296,24 @@ struct InstallableStorePath : Installable
Buildables toBuildables() override
{
- std::map<std::string, StorePath> outputs;
- outputs.insert_or_assign("out", storePath);
- Buildable b{
- .drvPath = storePath.isDerivation() ? storePath : std::optional<StorePath>(),
- .outputs = std::move(outputs)
- };
- Buildables bs;
- bs.push_back(std::move(b));
- return bs;
+ if (storePath.isDerivation()) {
+ std::map<std::string, StorePath> outputs;
+ for (auto & [name, output] : store->readDerivation(storePath).outputs)
+ outputs.emplace(name, output.path);
+ return {
+ Buildable {
+ .drvPath = storePath,
+ .outputs = std::move(outputs)
+ }
+ };
+ } else {
+ return {
+ Buildable {
+ .drvPath = {},
+ .outputs = {{"out", storePath}}
+ }
+ };
+ }
}
std::optional<StorePath> getStorePath() override