libstore: asyncify writeDerivation
Change-Id: Ia4e25dbc84e522b27c5257564febbd1ccf4df8a3
This commit is contained in:
@@ -1109,7 +1109,7 @@ drvName, Bindings * attrs, Value & v)
|
||||
}
|
||||
|
||||
/* Write the resulting term into the Nix store directory. */
|
||||
auto drvPath = writeDerivation(*state.ctx.store, drv, state.ctx.repair);
|
||||
auto drvPath = state.aio.blockOn(writeDerivation(*state.ctx.store, drv, state.ctx.repair));
|
||||
auto drvPathS = state.ctx.store->printStorePath(drvPath);
|
||||
|
||||
printMsg(lvlChatty, "instantiated '%1%' -> '%2%'", drvName, drvPathS);
|
||||
|
||||
@@ -604,7 +604,7 @@ try {
|
||||
assert(attempt);
|
||||
Derivation drvResolved { std::move(*attempt) };
|
||||
|
||||
auto pathResolved = writeDerivation(worker.store, drvResolved);
|
||||
auto pathResolved = TRY_AWAIT(writeDerivation(worker.store, drvResolved));
|
||||
|
||||
auto msg = fmt("resolved derivation: '%s' -> '%s'",
|
||||
worker.store.printStorePath(drvPath),
|
||||
|
||||
@@ -645,7 +645,7 @@ static void performOp(AsyncIoRoot & aio, TunnelLogger * logger, ref<Store> store
|
||||
|
||||
Derivation drv2;
|
||||
static_cast<BasicDerivation &>(drv2) = drv;
|
||||
drvPath = writeDerivation(*store, Derivation { drv2 });
|
||||
drvPath = aio.blockOn(writeDerivation(*store, Derivation { drv2 }));
|
||||
}
|
||||
|
||||
auto res = aio.blockOn(store->buildDerivation(drvPath, drv, buildMode));
|
||||
|
||||
@@ -134,9 +134,9 @@ bool BasicDerivation::isBuiltin() const
|
||||
}
|
||||
|
||||
|
||||
StorePath writeDerivation(Store & store,
|
||||
kj::Promise<Result<StorePath>> writeDerivation(Store & store,
|
||||
const Derivation & drv, RepairFlag repair, bool readOnly)
|
||||
{
|
||||
try {
|
||||
auto references = drv.inputSrcs;
|
||||
for (auto & i : drv.inputDrvs.map)
|
||||
references.insert(i.first);
|
||||
@@ -145,9 +145,11 @@ StorePath writeDerivation(Store & store,
|
||||
held during a garbage collection). */
|
||||
auto suffix = std::string(drv.name) + drvExtension;
|
||||
auto contents = drv.unparse(store, false);
|
||||
return readOnly || settings.readOnlyMode
|
||||
co_return readOnly || settings.readOnlyMode
|
||||
? store.computeStorePathForText(suffix, contents, references)
|
||||
: store.addTextToStore(suffix, contents, references, repair);
|
||||
} catch (...) {
|
||||
co_return result::current_exception();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
///@file
|
||||
|
||||
#include "lix/libstore/path.hh"
|
||||
#include "lix/libutil/result.hh"
|
||||
#include "lix/libutil/types.hh"
|
||||
#include "lix/libutil/hash.hh"
|
||||
#include "lix/libstore/content-address.hh"
|
||||
@@ -11,6 +12,7 @@
|
||||
#include "lix/libutil/comparator.hh"
|
||||
#include "lix/libutil/variant-wrapper.hh"
|
||||
|
||||
#include <kj/async.h>
|
||||
#include <map>
|
||||
#include <variant>
|
||||
|
||||
@@ -382,7 +384,7 @@ class Store;
|
||||
/**
|
||||
* Write a derivation to the Nix store, and return its path.
|
||||
*/
|
||||
StorePath writeDerivation(Store & store,
|
||||
kj::Promise<Result<StorePath>> writeDerivation(Store & store,
|
||||
const Derivation & drv,
|
||||
RepairFlag repair = NoRepair,
|
||||
bool readOnly = false);
|
||||
|
||||
@@ -1433,7 +1433,7 @@ try {
|
||||
// resolved derivation, so we need to get it first
|
||||
auto resolvedDrv = drv.tryResolve(*this);
|
||||
if (resolvedDrv)
|
||||
co_return writeDerivation(*this, *resolvedDrv, NoRepair, true);
|
||||
co_return TRY_AWAIT(writeDerivation(*this, *resolvedDrv, NoRepair, true));
|
||||
}
|
||||
|
||||
co_return path;
|
||||
|
||||
@@ -32,11 +32,11 @@ struct CmdAddDerivation : MixDryRun, StoreCommand
|
||||
|
||||
auto drv = Derivation::fromJSON(*store, json);
|
||||
|
||||
auto drvPath = writeDerivation(*store, drv, NoRepair, /* read only */ dryRun);
|
||||
auto drvPath = aio().blockOn(writeDerivation(*store, drv, NoRepair, /* read only */ dryRun));
|
||||
|
||||
drv.checkInvariants(*store, drvPath);
|
||||
|
||||
writeDerivation(*store, drv, NoRepair, dryRun);
|
||||
aio().blockOn(writeDerivation(*store, drv, NoRepair, dryRun));
|
||||
|
||||
logger->cout("%s", store->printStorePath(drvPath));
|
||||
}
|
||||
|
||||
+1
-1
@@ -256,7 +256,7 @@ try {
|
||||
}
|
||||
}
|
||||
|
||||
auto shellDrvPath = writeDerivation(*evalStore, drv);
|
||||
auto shellDrvPath = TRY_AWAIT(writeDerivation(*evalStore, drv));
|
||||
|
||||
/* Build the derivation. */
|
||||
TRY_AWAIT(store->buildPaths(
|
||||
|
||||
Reference in New Issue
Block a user