forked from lix-project/lix
Make --no-eval-cache a global setting
This commit is contained in:
parent
6146447842
commit
2ffc058950
|
@ -375,6 +375,9 @@ struct EvalSettings : Config
|
||||||
|
|
||||||
Setting<bool> traceFunctionCalls{this, false, "trace-function-calls",
|
Setting<bool> traceFunctionCalls{this, false, "trace-function-calls",
|
||||||
"Emit log messages for each function entry and exit at the 'vomit' log level (-vvvv)."};
|
"Emit log messages for each function entry and exit at the 'vomit' log level (-vvvv)."};
|
||||||
|
|
||||||
|
Setting<bool> useEvalCache{this, true, "eval-cache",
|
||||||
|
"Whether to use the flake evaluation cache."};
|
||||||
};
|
};
|
||||||
|
|
||||||
extern EvalSettings evalSettings;
|
extern EvalSettings evalSettings;
|
||||||
|
|
|
@ -8,7 +8,7 @@ namespace nix {
|
||||||
|
|
||||||
App Installable::toApp(EvalState & state)
|
App Installable::toApp(EvalState & state)
|
||||||
{
|
{
|
||||||
auto [cursor, attrPath] = getCursor(state, true);
|
auto [cursor, attrPath] = getCursor(state);
|
||||||
|
|
||||||
auto type = cursor->getAttr("type")->getString();
|
auto type = cursor->getAttr("type")->getString();
|
||||||
|
|
||||||
|
|
|
@ -572,7 +572,7 @@ struct CmdFlakeInitCommon : virtual Args, EvalCommand
|
||||||
Strings{templateName == "" ? "defaultTemplate" : templateName},
|
Strings{templateName == "" ? "defaultTemplate" : templateName},
|
||||||
Strings(attrsPathPrefixes), lockFlags);
|
Strings(attrsPathPrefixes), lockFlags);
|
||||||
|
|
||||||
auto [cursor, attrPath] = installable.getCursor(*evalState, true);
|
auto [cursor, attrPath] = installable.getCursor(*evalState);
|
||||||
|
|
||||||
auto templateDir = cursor->getAttr("path")->getString();
|
auto templateDir = cursor->getAttr("path")->getString();
|
||||||
|
|
||||||
|
@ -782,7 +782,6 @@ struct CmdFlakeArchive : FlakeCommand, MixJSON, MixDryRun
|
||||||
struct CmdFlakeShow : FlakeCommand
|
struct CmdFlakeShow : FlakeCommand
|
||||||
{
|
{
|
||||||
bool showLegacy = false;
|
bool showLegacy = false;
|
||||||
bool useEvalCache = true;
|
|
||||||
|
|
||||||
CmdFlakeShow()
|
CmdFlakeShow()
|
||||||
{
|
{
|
||||||
|
@ -791,12 +790,6 @@ struct CmdFlakeShow : FlakeCommand
|
||||||
.description = "show the contents of the 'legacyPackages' output",
|
.description = "show the contents of the 'legacyPackages' output",
|
||||||
.handler = {&showLegacy, true}
|
.handler = {&showLegacy, true}
|
||||||
});
|
});
|
||||||
|
|
||||||
addFlag({
|
|
||||||
.longName = "no-eval-cache",
|
|
||||||
.description = "do not use the flake evaluation cache",
|
|
||||||
.handler = {[&]() { useEvalCache = false; }}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string description() override
|
std::string description() override
|
||||||
|
@ -934,7 +927,7 @@ struct CmdFlakeShow : FlakeCommand
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
auto cache = openEvalCache(*state, flake, useEvalCache);
|
auto cache = openEvalCache(*state, flake);
|
||||||
|
|
||||||
visit(*cache->getRoot(), {}, fmt(ANSI_BOLD "%s" ANSI_NORMAL, flake->flake.lockedRef), "");
|
visit(*cache->getRoot(), {}, fmt(ANSI_BOLD "%s" ANSI_NORMAL, flake->flake.lockedRef), "");
|
||||||
}
|
}
|
||||||
|
|
|
@ -183,8 +183,7 @@ void completeFlakeRefWithFragment(
|
||||||
auto flakeRef = parseFlakeRef(flakeRefS, absPath("."));
|
auto flakeRef = parseFlakeRef(flakeRefS, absPath("."));
|
||||||
|
|
||||||
auto evalCache = openEvalCache(*evalState,
|
auto evalCache = openEvalCache(*evalState,
|
||||||
std::make_shared<flake::LockedFlake>(lockFlake(*evalState, flakeRef, lockFlags)),
|
std::make_shared<flake::LockedFlake>(lockFlake(*evalState, flakeRef, lockFlags)));
|
||||||
true);
|
|
||||||
|
|
||||||
auto root = evalCache->getRoot();
|
auto root = evalCache->getRoot();
|
||||||
|
|
||||||
|
@ -273,7 +272,7 @@ Buildable Installable::toBuildable()
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::pair<std::shared_ptr<eval_cache::AttrCursor>, std::string>>
|
std::vector<std::pair<std::shared_ptr<eval_cache::AttrCursor>, std::string>>
|
||||||
Installable::getCursors(EvalState & state, bool useEvalCache)
|
Installable::getCursors(EvalState & state)
|
||||||
{
|
{
|
||||||
auto evalCache =
|
auto evalCache =
|
||||||
std::make_shared<nix::eval_cache::EvalCache>(std::nullopt, state,
|
std::make_shared<nix::eval_cache::EvalCache>(std::nullopt, state,
|
||||||
|
@ -282,9 +281,9 @@ Installable::getCursors(EvalState & state, bool useEvalCache)
|
||||||
}
|
}
|
||||||
|
|
||||||
std::pair<std::shared_ptr<eval_cache::AttrCursor>, std::string>
|
std::pair<std::shared_ptr<eval_cache::AttrCursor>, std::string>
|
||||||
Installable::getCursor(EvalState & state, bool useEvalCache)
|
Installable::getCursor(EvalState & state)
|
||||||
{
|
{
|
||||||
auto cursors = getCursors(state, useEvalCache);
|
auto cursors = getCursors(state);
|
||||||
if (cursors.empty())
|
if (cursors.empty())
|
||||||
throw Error("cannot find flake attribute '%s'", what());
|
throw Error("cannot find flake attribute '%s'", what());
|
||||||
return cursors[0];
|
return cursors[0];
|
||||||
|
@ -420,12 +419,11 @@ Value * InstallableFlake::getFlakeOutputs(EvalState & state, const flake::Locked
|
||||||
|
|
||||||
ref<eval_cache::EvalCache> openEvalCache(
|
ref<eval_cache::EvalCache> openEvalCache(
|
||||||
EvalState & state,
|
EvalState & state,
|
||||||
std::shared_ptr<flake::LockedFlake> lockedFlake,
|
std::shared_ptr<flake::LockedFlake> lockedFlake)
|
||||||
bool useEvalCache)
|
|
||||||
{
|
{
|
||||||
auto fingerprint = lockedFlake->getFingerprint();
|
auto fingerprint = lockedFlake->getFingerprint();
|
||||||
return make_ref<nix::eval_cache::EvalCache>(
|
return make_ref<nix::eval_cache::EvalCache>(
|
||||||
useEvalCache && evalSettings.pureEval
|
evalSettings.useEvalCache && evalSettings.pureEval
|
||||||
? std::optional { std::cref(fingerprint) }
|
? std::optional { std::cref(fingerprint) }
|
||||||
: std::nullopt,
|
: std::nullopt,
|
||||||
state,
|
state,
|
||||||
|
@ -460,10 +458,9 @@ static std::string showAttrPaths(const std::vector<std::string> & paths)
|
||||||
|
|
||||||
std::tuple<std::string, FlakeRef, InstallableValue::DerivationInfo> InstallableFlake::toDerivation()
|
std::tuple<std::string, FlakeRef, InstallableValue::DerivationInfo> InstallableFlake::toDerivation()
|
||||||
{
|
{
|
||||||
|
|
||||||
auto lockedFlake = getLockedFlake();
|
auto lockedFlake = getLockedFlake();
|
||||||
|
|
||||||
auto cache = openEvalCache(*state, lockedFlake, true);
|
auto cache = openEvalCache(*state, lockedFlake);
|
||||||
auto root = cache->getRoot();
|
auto root = cache->getRoot();
|
||||||
|
|
||||||
for (auto & attrPath : getActualAttrPaths()) {
|
for (auto & attrPath : getActualAttrPaths()) {
|
||||||
|
@ -517,11 +514,10 @@ std::pair<Value *, Pos> InstallableFlake::toValue(EvalState & state)
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::pair<std::shared_ptr<eval_cache::AttrCursor>, std::string>>
|
std::vector<std::pair<std::shared_ptr<eval_cache::AttrCursor>, std::string>>
|
||||||
InstallableFlake::getCursors(EvalState & state, bool useEvalCache)
|
InstallableFlake::getCursors(EvalState & state)
|
||||||
{
|
{
|
||||||
auto evalCache = openEvalCache(state,
|
auto evalCache = openEvalCache(state,
|
||||||
std::make_shared<flake::LockedFlake>(lockFlake(state, flakeRef, lockFlags)),
|
std::make_shared<flake::LockedFlake>(lockFlake(state, flakeRef, lockFlags)));
|
||||||
useEvalCache);
|
|
||||||
|
|
||||||
auto root = evalCache->getRoot();
|
auto root = evalCache->getRoot();
|
||||||
|
|
||||||
|
|
|
@ -62,10 +62,10 @@ struct Installable
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual std::vector<std::pair<std::shared_ptr<eval_cache::AttrCursor>, std::string>>
|
virtual std::vector<std::pair<std::shared_ptr<eval_cache::AttrCursor>, std::string>>
|
||||||
getCursors(EvalState & state, bool useEvalCache);
|
getCursors(EvalState & state);
|
||||||
|
|
||||||
std::pair<std::shared_ptr<eval_cache::AttrCursor>, std::string>
|
std::pair<std::shared_ptr<eval_cache::AttrCursor>, std::string>
|
||||||
getCursor(EvalState & state, bool useEvalCache);
|
getCursor(EvalState & state);
|
||||||
|
|
||||||
virtual FlakeRef nixpkgsFlakeRef() const
|
virtual FlakeRef nixpkgsFlakeRef() const
|
||||||
{
|
{
|
||||||
|
@ -118,7 +118,7 @@ struct InstallableFlake : InstallableValue
|
||||||
std::pair<Value *, Pos> toValue(EvalState & state) override;
|
std::pair<Value *, Pos> toValue(EvalState & state) override;
|
||||||
|
|
||||||
std::vector<std::pair<std::shared_ptr<eval_cache::AttrCursor>, std::string>>
|
std::vector<std::pair<std::shared_ptr<eval_cache::AttrCursor>, std::string>>
|
||||||
getCursors(EvalState & state, bool useEvalCache) override;
|
getCursors(EvalState & state) override;
|
||||||
|
|
||||||
std::shared_ptr<flake::LockedFlake> getLockedFlake() const;
|
std::shared_ptr<flake::LockedFlake> getLockedFlake() const;
|
||||||
|
|
||||||
|
@ -127,7 +127,6 @@ struct InstallableFlake : InstallableValue
|
||||||
|
|
||||||
ref<eval_cache::EvalCache> openEvalCache(
|
ref<eval_cache::EvalCache> openEvalCache(
|
||||||
EvalState & state,
|
EvalState & state,
|
||||||
std::shared_ptr<flake::LockedFlake> lockedFlake,
|
std::shared_ptr<flake::LockedFlake> lockedFlake);
|
||||||
bool useEvalCache);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -177,7 +177,7 @@ struct CmdSearch : InstallableCommand, MixJSON
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
for (auto & [cursor, prefix] : installable->getCursors(*state, true))
|
for (auto & [cursor, prefix] : installable->getCursors(*state))
|
||||||
visit(*cursor, parseAttrPath(*state, prefix));
|
visit(*cursor, parseAttrPath(*state, prefix));
|
||||||
|
|
||||||
if (!json && !results)
|
if (!json && !results)
|
||||||
|
|
Loading…
Reference in a new issue