mirror of
https://github.com/NixOS/nix.git
synced 2024-11-22 14:52:55 +00:00
C API: refactor nix_store_realise
This commit is contained in:
parent
1a574c6c60
commit
31fbb24329
@ -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<nix::DerivedPath> 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());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user