From 31fbb24329851d4747d64319f62da9c7e77ead35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Luis=20Lafuente?= Date: Thu, 29 Feb 2024 16:32:49 +0100 Subject: [PATCH] C API: refactor nix_store_realise --- src/libstore/c/nix_api_store.cc | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/libstore/c/nix_api_store.cc b/src/libstore/c/nix_api_store.cc index c997019f9..199f5526a 100644 --- a/src/libstore/c/nix_api_store.cc +++ b/src/libstore/c/nix_api_store.cc @@ -5,6 +5,7 @@ #include "path.hh" #include "store-api.hh" +#include "build-result.hh" #include "globals.hh" @@ -110,16 +111,19 @@ nix_err nix_store_realise( if (context) context->last_err_code = NIX_OK; try { - store->ptr->buildPaths({ - nix::DerivedPath::Built{ - .drvPath = nix::makeConstantStorePathRef(path->path), - .outputs = nix::OutputsSpec::All{}, - }, - }); + + const std::vector paths{nix::DerivedPath::Built{ + .drvPath = nix::makeConstantStorePathRef(path->path), .outputs = nix::OutputsSpec::All{}}}; + + const auto nixStore = store->ptr; + auto results = nixStore->buildPathsWithResults(paths, nix::bmNormal, nixStore); + if (callback) { - for (auto & [outputName, outputPath] : store->ptr->queryDerivationOutputMap(path->path)) { - auto op = store->ptr->printStorePath(outputPath); - callback(userdata, outputName.c_str(), op.c_str()); + for (const auto & result : results) { + for (const auto & [outputName, realisation] : result.builtOutputs) { + auto op = store->ptr->printStorePath(realisation.outPath); + callback(userdata, outputName.c_str(), op.c_str()); + } } } }