C API: refactor nix_store_realise

This commit is contained in:
José Luis Lafuente 2024-02-29 16:32:49 +01:00 committed by José Luis Lafuente
parent 1a574c6c60
commit 31fbb24329
No known key found for this signature in database
GPG key ID: 8A3455EBE455489A

View file

@ -5,6 +5,7 @@
#include "path.hh" #include "path.hh"
#include "store-api.hh" #include "store-api.hh"
#include "build-result.hh"
#include "globals.hh" #include "globals.hh"
@ -110,16 +111,19 @@ nix_err nix_store_realise(
if (context) if (context)
context->last_err_code = NIX_OK; context->last_err_code = NIX_OK;
try { try {
store->ptr->buildPaths({
nix::DerivedPath::Built{ const std::vector<nix::DerivedPath> paths{nix::DerivedPath::Built{
.drvPath = nix::makeConstantStorePathRef(path->path), .drvPath = nix::makeConstantStorePathRef(path->path), .outputs = nix::OutputsSpec::All{}}};
.outputs = nix::OutputsSpec::All{},
}, const auto nixStore = store->ptr;
}); auto results = nixStore->buildPathsWithResults(paths, nix::bmNormal, nixStore);
if (callback) { if (callback) {
for (auto & [outputName, outputPath] : store->ptr->queryDerivationOutputMap(path->path)) { for (const auto & result : results) {
auto op = store->ptr->printStorePath(outputPath); for (const auto & [outputName, realisation] : result.builtOutputs) {
callback(userdata, outputName.c_str(), op.c_str()); auto op = store->ptr->printStorePath(realisation.outPath);
callback(userdata, outputName.c_str(), op.c_str());
}
} }
} }
} }