1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-20 01:09:37 +01:00

First attempt at caching the evaluation in nix build

This commit is contained in:
regnat 2021-06-04 11:39:29 +02:00
parent ffec547ebc
commit 3e261410bc

View file

@ -498,25 +498,42 @@ std::tuple<std::string, FlakeRef, InstallableValue::DerivationInfo> InstallableF
auto root = cache->getRoot(); auto root = cache->getRoot();
for (auto & attrPath : getActualAttrPaths()) { for (auto & attrPath : getActualAttrPaths()) {
auto attr = root->findAlongAttrPath( auto emptyArgs = state->allocBindings(0);
parseAttrPath(*state, attrPath), auto drvPathAttrPath = attrPath + ".drvPath";
true auto drvOutputNameAttrPath = attrPath + ".outputName";
auto drvOutputPathAttrPath = attrPath + ".outPath";
try {
auto [drvPathValue, pos] = findAlongAttrPath(
*state,
drvPathAttrPath,
*emptyArgs,
*getFlakeOutputs(*state, *lockedFlake)
); );
auto drvPath = state->forceString(*drvPathValue);
if (!attr) continue; auto drvOutputNameValue = findAlongAttrPath(
*state,
if (!attr->isDerivation()) drvOutputNameAttrPath,
throw Error("flake output attribute '%s' is not a derivation", attrPath); *emptyArgs,
*getFlakeOutputs(*state, *lockedFlake)
auto drvPath = attr->forceDerivation(); ).first;
auto drvOutputName = state->forceString(*drvOutputNameValue);
auto drvOutputPathValue = findAlongAttrPath(
*state,
drvOutputPathAttrPath,
*emptyArgs,
*getFlakeOutputs(*state, *lockedFlake)
).first;
auto drvOutputPath = state->forceString(*drvOutputPathValue);
auto drvInfo = DerivationInfo{ auto drvInfo = DerivationInfo{
std::move(drvPath), state->store->parseStorePath(drvPath),
state->store->maybeParseStorePath(attr->getAttr(state->sOutPath)->getString()), state->store->maybeParseStorePath(drvOutputPath), // FIXME: set to something when relevant?
attr->getAttr(state->sOutputName)->getString() drvOutputName
}; };
return {attrPath, lockedFlake->flake.lockedRef, std::move(drvInfo)}; return {attrPath, lockedFlake->flake.lockedRef, std::move(drvInfo)};
} catch (AttrPathNotFound & e) {
}
} }
throw Error("flake '%s' does not provide attribute %s", throw Error("flake '%s' does not provide attribute %s",