mirror of
https://github.com/NixOS/nix.git
synced 2025-11-19 16:59:35 +01:00
First attempt at caching the evaluation in nix build
This commit is contained in:
parent
ffec547ebc
commit
3e261410bc
1 changed files with 34 additions and 17 deletions
|
|
@ -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);
|
||||||
|
auto drvOutputNameValue = findAlongAttrPath(
|
||||||
|
*state,
|
||||||
|
drvOutputNameAttrPath,
|
||||||
|
*emptyArgs,
|
||||||
|
*getFlakeOutputs(*state, *lockedFlake)
|
||||||
|
).first;
|
||||||
|
auto drvOutputName = state->forceString(*drvOutputNameValue);
|
||||||
|
auto drvOutputPathValue = findAlongAttrPath(
|
||||||
|
*state,
|
||||||
|
drvOutputPathAttrPath,
|
||||||
|
*emptyArgs,
|
||||||
|
*getFlakeOutputs(*state, *lockedFlake)
|
||||||
|
).first;
|
||||||
|
auto drvOutputPath = state->forceString(*drvOutputPathValue);
|
||||||
|
|
||||||
if (!attr) continue;
|
auto drvInfo = DerivationInfo{
|
||||||
|
state->store->parseStorePath(drvPath),
|
||||||
|
state->store->maybeParseStorePath(drvOutputPath), // FIXME: set to something when relevant?
|
||||||
|
drvOutputName
|
||||||
|
};
|
||||||
|
|
||||||
if (!attr->isDerivation())
|
return {attrPath, lockedFlake->flake.lockedRef, std::move(drvInfo)};
|
||||||
throw Error("flake output attribute '%s' is not a derivation", attrPath);
|
} catch (AttrPathNotFound & e) {
|
||||||
|
}
|
||||||
auto drvPath = attr->forceDerivation();
|
|
||||||
|
|
||||||
auto drvInfo = DerivationInfo{
|
|
||||||
std::move(drvPath),
|
|
||||||
state->store->maybeParseStorePath(attr->getAttr(state->sOutPath)->getString()),
|
|
||||||
attr->getAttr(state->sOutputName)->getString()
|
|
||||||
};
|
|
||||||
|
|
||||||
return {attrPath, lockedFlake->flake.lockedRef, std::move(drvInfo)};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
throw Error("flake '%s' does not provide attribute %s",
|
throw Error("flake '%s' does not provide attribute %s",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue