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

Set the cache when opening a flake

This commit is contained in:
regnat 2021-06-03 06:59:19 +02:00
parent 6396416dfa
commit 8d95e1f299
3 changed files with 27 additions and 3 deletions

View file

@ -1173,10 +1173,11 @@ bool EvalState::getAttrField(Value & attrs, const std::vector<Symbol> & selector
auto [ cacheResult, resultingCursor ] = eval_cache.getValue(*this, selector, dest);
switch (cacheResult.returnCode) {
case ValueCache::CacheHit:
if (cacheResult.lastQueriedSymbolIfMissing)
return false;
return true;
case ValueCache::CacheMiss:
return false;
case ValueCache::Forward: // Fixme: Handle properly
case ValueCache::CacheMiss: // FIXME: Handle properly
case ValueCache::Forward: // FIXME: Handle properly
case ValueCache::NoCacheKey:
case ValueCache::UnCacheable:
;
@ -2162,6 +2163,21 @@ Strings EvalSettings::getDefaultNixPath()
return res;
}
std::shared_ptr<tree_cache::Cache> EvalState::openTreeCache(Hash cacheKey)
{
if (auto iter = evalCache.find(cacheKey); iter != evalCache.end())
return iter->second;
if (!(evalSettings.useEvalCache && evalSettings.pureEval))
return nullptr;
auto thisCache = tree_cache::Cache::tryCreate(
cacheKey,
symbols
);
evalCache.insert({cacheKey, thisCache});
return thisCache;
}
EvalSettings evalSettings;
static GlobalConfig::Register rEvalSettings(&evalSettings);