diff --git a/lix/libstore/derivations.cc b/lix/libstore/derivations.cc index f0c6e2188..7286640cb 100644 --- a/lix/libstore/derivations.cc +++ b/lix/libstore/derivations.cc @@ -732,110 +732,6 @@ std::string hashPlaceholder(const OutputNameView outputName) -static kj::Promise> -rewriteDerivation(Store & store, BasicDerivation & drv, const StringMap & rewrites) -try { - debug("Rewriting the derivation"); - - for (auto & rewrite : rewrites) { - debug("rewriting %s as %s", rewrite.first, rewrite.second); - } - - drv.builder = rewriteStrings(drv.builder, rewrites); - for (auto & arg : drv.args) { - arg = rewriteStrings(arg, rewrites); - } - - StringPairs newEnv; - for (auto & envVar : drv.env) { - auto envName = rewriteStrings(envVar.first, rewrites); - auto envValue = rewriteStrings(envVar.second, rewrites); - newEnv.emplace(envName, envValue); - } - drv.env = newEnv; - - TRY_AWAIT(hashDerivationModulo(store, Derivation(drv), true)); - co_return result::success(); -} catch (...) { - co_return result::current_exception(); -} - -kj::Promise>> -Derivation::tryResolve(Store & store, Store * evalStore) const -try { - std::map, StorePath> inputDrvOutputs; - - // NOLINTNEXTLINE(cppcoreguidelines-avoid-capturing-lambda-coroutines) - auto accum = [&](auto & inputDrv, auto & node) -> kj::Promise> { - try { - for (auto & [outputName, outputPath] : - TRY_AWAIT(store.queryPartialDerivationOutputMap(inputDrv, evalStore))) - { - if (outputPath) { - inputDrvOutputs.insert_or_assign({inputDrv, outputName}, *outputPath); - } - } - co_return result::success(); - } catch (...) { - co_return result::current_exception(); - } - }; - - for (auto & [inputDrv, node] : inputDrvs) - TRY_AWAIT(accum(inputDrv, node)); - - co_return TRY_AWAIT(tryResolve(store, inputDrvOutputs)); -} catch (...) { - co_return result::current_exception(); -} - -static bool tryResolveInput( - Store & store, StorePathSet & inputSrcs, StringMap & inputRewrites, - const StorePath & inputDrv, const StringSet & inputNode, - const std::map, StorePath> & inputDrvOutputs) -{ - auto getOutput = [&](const std::string & outputName) { - auto * actualPathOpt = get(inputDrvOutputs, { inputDrv, outputName }); - if (!actualPathOpt) - warn("output %s of input %s missing, aborting the resolving", - outputName, - store.printStorePath(inputDrv) - ); - return actualPathOpt; - }; - - for (auto & outputName : inputNode) { - auto actualPathOpt = getOutput(outputName); - if (!actualPathOpt) return false; - auto actualPath = *actualPathOpt; - inputSrcs.insert(std::move(actualPath)); - } - - return true; -} - -kj::Promise>> Derivation::tryResolve( - Store & store, - const std::map, StorePath> & inputDrvOutputs) const -try { - BasicDerivation resolved { *this }; - - // Input paths that we'll want to rewrite in the derivation - StringMap inputRewrites; - - for (auto & [inputDrv, inputNode] : inputDrvs) - if (!tryResolveInput(store, resolved.inputSrcs, inputRewrites, - inputDrv, inputNode, inputDrvOutputs)) - co_return std::nullopt; - - TRY_AWAIT(rewriteDerivation(store, resolved, inputRewrites)); - - co_return resolved; -} catch (...) { - co_return result::current_exception(); -} - - kj::Promise> Derivation::checkInvariants(Store & store, const StorePath & drvPath) const try { diff --git a/lix/libstore/derivations.hh b/lix/libstore/derivations.hh index 8b4ff6179..8f3870ce4 100644 --- a/lix/libstore/derivations.hh +++ b/lix/libstore/derivations.hh @@ -234,27 +234,6 @@ struct Derivation : BasicDerivation std::string unparse(const Store & store, bool maskOutputs, std::map * actualInputs = nullptr) const; - /** - * Return the underlying basic derivation but with these changes: - * - * 1. Input drvs are emptied, but the outputs of them that were used - * are added directly to input sources. - * - * 2. Input placeholders are replaced with realized input store - * paths. - */ - kj::Promise>> - tryResolve(Store & store, Store * evalStore = nullptr) const; - - /** - * Like the above, but instead of querying the Nix database for - * realisations, uses a given mapping from input derivation paths + - * output names to actual output store paths. - */ - kj::Promise>> tryResolve( - Store & store, - const std::map, StorePath> & inputDrvOutputs) const; - /** * Check that the derivation is valid and does not present any * illegal states.