aboutsummaryrefslogtreecommitdiff
path: root/src/libcmd/installables.cc
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2022-03-09 14:37:14 +0100
committerGitHub <noreply@github.com>2022-03-09 14:37:14 +0100
commit1c1a7074dae04414268d47c5b94e8d78afee8770 (patch)
tree7509dfda4c52ecab6e972e3f1ed9d3b1d0360b5b /src/libcmd/installables.cc
parent92b8d4d8861b908a7ec500526a84155c597d6d2b (diff)
parent761242afa08d5c9280ba6bd63a310b4334b83bb2 (diff)
Merge pull request #6221 from NixOS/build-paths-with-results
Add Store::buildPathsWithResults()
Diffstat (limited to 'src/libcmd/installables.cc')
-rw-r--r--src/libcmd/installables.cc35
1 files changed, 28 insertions, 7 deletions
diff --git a/src/libcmd/installables.cc b/src/libcmd/installables.cc
index 03f3bd409..b7623d4ba 100644
--- a/src/libcmd/installables.cc
+++ b/src/libcmd/installables.cc
@@ -12,6 +12,7 @@
#include "eval-cache.hh"
#include "url.hh"
#include "registry.hh"
+#include "build-result.hh"
#include <regex>
#include <queue>
@@ -769,8 +770,7 @@ BuiltPaths getBuiltPaths(ref<Store> evalStore, ref<Store> store, const DerivedPa
throw Error(
"the derivation '%s' doesn't have an output named '%s'",
store->printStorePath(bfd.drvPath), output);
- if (settings.isExperimentalFeatureEnabled(
- Xp::CaDerivations)) {
+ if (settings.isExperimentalFeatureEnabled(Xp::CaDerivations)) {
auto outputId =
DrvOutput{outputHashes.at(output), output};
auto realisation =
@@ -816,12 +816,33 @@ BuiltPaths Installable::build(
pathsToBuild.insert(pathsToBuild.end(), b.begin(), b.end());
}
- if (mode == Realise::Nothing || mode == Realise::Derivation)
+ switch (mode) {
+ case Realise::Nothing:
+ case Realise::Derivation:
printMissing(store, pathsToBuild, lvlError);
- else if (mode == Realise::Outputs)
- store->buildPaths(pathsToBuild, bMode, evalStore);
-
- return getBuiltPaths(evalStore, store, pathsToBuild);
+ return getBuiltPaths(evalStore, store, pathsToBuild);
+ case Realise::Outputs: {
+ BuiltPaths res;
+ for (auto & buildResult : store->buildPathsWithResults(pathsToBuild, bMode, evalStore)) {
+ if (!buildResult.success())
+ buildResult.rethrow();
+ std::visit(overloaded {
+ [&](const DerivedPath::Built & bfd) {
+ std::map<std::string, StorePath> outputs;
+ for (auto & path : buildResult.builtOutputs)
+ outputs.emplace(path.first.outputName, path.second.outPath);
+ res.push_back(BuiltPath::Built { bfd.drvPath, outputs });
+ },
+ [&](const DerivedPath::Opaque & bo) {
+ res.push_back(BuiltPath::Opaque { bo.path });
+ },
+ }, buildResult.path.raw());
+ }
+ return res;
+ }
+ default:
+ assert(false);
+ }
}
BuiltPaths Installable::toBuiltPaths(