mirror of
https://github.com/NixOS/nix
synced 2025-07-03 02:01:48 +02:00
Move the InputCache to EvalState
This commit is contained in:
parent
62565ce7ce
commit
e099a5bc67
7 changed files with 16 additions and 12 deletions
|
@ -28,7 +28,6 @@
|
||||||
#include "nix/expr/print.hh"
|
#include "nix/expr/print.hh"
|
||||||
#include "nix/util/ref.hh"
|
#include "nix/util/ref.hh"
|
||||||
#include "nix/expr/value.hh"
|
#include "nix/expr/value.hh"
|
||||||
#include "nix/fetchers/input-cache.hh"
|
|
||||||
|
|
||||||
#include "nix/util/strings.hh"
|
#include "nix/util/strings.hh"
|
||||||
|
|
||||||
|
@ -459,7 +458,6 @@ ProcessLineResult NixRepl::processLine(std::string line)
|
||||||
|
|
||||||
else if (command == ":l" || command == ":load") {
|
else if (command == ":l" || command == ":load") {
|
||||||
state->resetFileCache();
|
state->resetFileCache();
|
||||||
fetchers::InputCache::getCache()->clear();
|
|
||||||
loadFile(arg);
|
loadFile(arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -469,7 +467,6 @@ ProcessLineResult NixRepl::processLine(std::string line)
|
||||||
|
|
||||||
else if (command == ":r" || command == ":reload") {
|
else if (command == ":r" || command == ":reload") {
|
||||||
state->resetFileCache();
|
state->resetFileCache();
|
||||||
fetchers::InputCache::getCache()->clear();
|
|
||||||
reloadFiles();
|
reloadFiles();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
#include "nix/util/url.hh"
|
#include "nix/util/url.hh"
|
||||||
#include "nix/fetchers/fetch-to-store.hh"
|
#include "nix/fetchers/fetch-to-store.hh"
|
||||||
#include "nix/fetchers/tarball.hh"
|
#include "nix/fetchers/tarball.hh"
|
||||||
|
#include "nix/fetchers/input-cache.hh"
|
||||||
|
|
||||||
#include "parser-tab.hh"
|
#include "parser-tab.hh"
|
||||||
|
|
||||||
|
@ -290,6 +291,7 @@ EvalState::EvalState(
|
||||||
)}
|
)}
|
||||||
, store(store)
|
, store(store)
|
||||||
, buildStore(buildStore ? buildStore : store)
|
, buildStore(buildStore ? buildStore : store)
|
||||||
|
, inputCache(fetchers::InputCache::create())
|
||||||
, debugRepl(nullptr)
|
, debugRepl(nullptr)
|
||||||
, debugStop(false)
|
, debugStop(false)
|
||||||
, trylevel(0)
|
, trylevel(0)
|
||||||
|
@ -1132,6 +1134,7 @@ void EvalState::resetFileCache()
|
||||||
{
|
{
|
||||||
fileEvalCache.clear();
|
fileEvalCache.clear();
|
||||||
fileParseCache.clear();
|
fileParseCache.clear();
|
||||||
|
inputCache->clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,10 @@ namespace nix {
|
||||||
constexpr size_t maxPrimOpArity = 8;
|
constexpr size_t maxPrimOpArity = 8;
|
||||||
|
|
||||||
class Store;
|
class Store;
|
||||||
namespace fetchers { struct Settings; }
|
namespace fetchers {
|
||||||
|
struct Settings;
|
||||||
|
struct InputCache;
|
||||||
|
}
|
||||||
struct EvalSettings;
|
struct EvalSettings;
|
||||||
class EvalState;
|
class EvalState;
|
||||||
class StorePath;
|
class StorePath;
|
||||||
|
@ -301,6 +304,8 @@ public:
|
||||||
|
|
||||||
RootValue vImportedDrvToDerivation = nullptr;
|
RootValue vImportedDrvToDerivation = nullptr;
|
||||||
|
|
||||||
|
ref<fetchers::InputCache> inputCache;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Debugger
|
* Debugger
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -202,7 +202,7 @@ static void fetchTree(
|
||||||
throw Error("input '%s' is not allowed to use the '__final' attribute", input.to_string());
|
throw Error("input '%s' is not allowed to use the '__final' attribute", input.to_string());
|
||||||
}
|
}
|
||||||
|
|
||||||
auto cachedInput = fetchers::InputCache::getCache()->getAccessor(state.store, input, false);
|
auto cachedInput = state.inputCache->getAccessor(state.store, input, false);
|
||||||
|
|
||||||
auto storePath = StorePath::random(input.getName());
|
auto storePath = StorePath::random(input.getName());
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@ struct InputCache
|
||||||
|
|
||||||
virtual void clear() = 0;
|
virtual void clear() = 0;
|
||||||
|
|
||||||
static ref<InputCache> getCache();
|
static ref<InputCache> create();
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,10 +72,9 @@ struct InputCacheImpl : InputCache
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
ref<InputCache> InputCache::getCache()
|
ref<InputCache> InputCache::create()
|
||||||
{
|
{
|
||||||
static auto cache = make_ref<InputCacheImpl>();
|
return make_ref<InputCacheImpl>();
|
||||||
return cache;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -353,7 +353,7 @@ static Flake getFlake(
|
||||||
CopyMode copyMode)
|
CopyMode copyMode)
|
||||||
{
|
{
|
||||||
// Fetch a lazy tree first.
|
// Fetch a lazy tree first.
|
||||||
auto cachedInput = fetchers::InputCache::getCache()->getAccessor(state.store, originalRef.input, useRegistries);
|
auto cachedInput = state.inputCache->getAccessor(state.store, originalRef.input, useRegistries);
|
||||||
|
|
||||||
auto resolvedRef = FlakeRef(std::move(cachedInput.resolvedInput), originalRef.subdir);
|
auto resolvedRef = FlakeRef(std::move(cachedInput.resolvedInput), originalRef.subdir);
|
||||||
auto lockedRef = FlakeRef(std::move(cachedInput.lockedInput), originalRef.subdir);
|
auto lockedRef = FlakeRef(std::move(cachedInput.lockedInput), originalRef.subdir);
|
||||||
|
@ -368,7 +368,7 @@ static Flake getFlake(
|
||||||
debug("refetching input '%s' due to self attribute", newLockedRef);
|
debug("refetching input '%s' due to self attribute", newLockedRef);
|
||||||
// FIXME: need to remove attrs that are invalidated by the changed input attrs, such as 'narHash'.
|
// FIXME: need to remove attrs that are invalidated by the changed input attrs, such as 'narHash'.
|
||||||
newLockedRef.input.attrs.erase("narHash");
|
newLockedRef.input.attrs.erase("narHash");
|
||||||
auto cachedInput2 = fetchers::InputCache::getCache()->getAccessor(state.store, newLockedRef.input, useRegistries);
|
auto cachedInput2 = state.inputCache->getAccessor(state.store, newLockedRef.input, useRegistries);
|
||||||
cachedInput.accessor = cachedInput2.accessor;
|
cachedInput.accessor = cachedInput2.accessor;
|
||||||
lockedRef = FlakeRef(std::move(cachedInput2.lockedInput), newLockedRef.subdir);
|
lockedRef = FlakeRef(std::move(cachedInput2.lockedInput), newLockedRef.subdir);
|
||||||
}
|
}
|
||||||
|
@ -734,7 +734,7 @@ LockedFlake lockFlake(
|
||||||
if (auto resolvedPath = resolveRelativePath()) {
|
if (auto resolvedPath = resolveRelativePath()) {
|
||||||
return {*resolvedPath, *input.ref};
|
return {*resolvedPath, *input.ref};
|
||||||
} else {
|
} else {
|
||||||
auto cachedInput = fetchers::InputCache::getCache()->getAccessor(state.store, input.ref->input, useRegistries);
|
auto cachedInput = state.inputCache->getAccessor(state.store, input.ref->input, useRegistries);
|
||||||
|
|
||||||
auto lockedRef = FlakeRef(std::move(cachedInput.lockedInput), input.ref->subdir);
|
auto lockedRef = FlakeRef(std::move(cachedInput.lockedInput), input.ref->subdir);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue