libcmd: munge evalSettings in the right place
these must be tampered with before the evaluator is created, *never* after. doing it any other way leads to interesting things like #596. fixes #596 Change-Id: Iea253ccce44b94b1243833837a3df93c795967d9
This commit is contained in:
@@ -77,7 +77,7 @@ struct EvalCommand : virtual StoreCommand, MixEvalArgs
|
||||
|
||||
ref<Store> getEvalStore();
|
||||
|
||||
ref<eval_cache::CachingEvaluator> getEvaluator();
|
||||
virtual ref<eval_cache::CachingEvaluator> getEvaluator();
|
||||
|
||||
private:
|
||||
std::shared_ptr<Store> evalStore;
|
||||
@@ -114,6 +114,8 @@ struct SourceExprCommand : virtual Args, MixFlakeOptions
|
||||
|
||||
SourceExprCommand();
|
||||
|
||||
ref<eval_cache::CachingEvaluator> getEvaluator() override;
|
||||
|
||||
Installables parseInstallables(
|
||||
EvalState & state, ref<Store> store, std::vector<std::string> ss);
|
||||
|
||||
|
||||
@@ -212,9 +212,7 @@ void SourceExprCommand::completeInstallable(EvalState & state, AddCompletions &
|
||||
if (file) {
|
||||
completions.setType(AddCompletions::Type::Attrs);
|
||||
|
||||
evalSettings.pureEval.override(false);
|
||||
auto evaluator = getEvaluator();
|
||||
evaluator->paths.allowedPaths.reset();
|
||||
|
||||
Expr & e = evaluator->parseExprFromFile(
|
||||
resolveExprPath(evaluator->paths.checkSourcePath(lookupFileArg(*evaluator, *file)))
|
||||
@@ -427,6 +425,16 @@ ref<eval_cache::EvalCache> openEvalCache(
|
||||
}
|
||||
}
|
||||
|
||||
ref<eval_cache::CachingEvaluator> SourceExprCommand::getEvaluator()
|
||||
{
|
||||
// FIXME: backward compatibility hack
|
||||
if (file) {
|
||||
evalSettings.pureEval.override(false);
|
||||
}
|
||||
|
||||
return EvalCommand::getEvaluator();
|
||||
}
|
||||
|
||||
Installables SourceExprCommand::parseInstallables(
|
||||
EvalState & state, ref<Store> store, std::vector<std::string> ss)
|
||||
{
|
||||
@@ -436,12 +444,6 @@ Installables SourceExprCommand::parseInstallables(
|
||||
if (file && expr)
|
||||
throw UsageError("'--file' and '--expr' are exclusive");
|
||||
|
||||
// FIXME: backward compatibility hack
|
||||
if (file) {
|
||||
evalSettings.pureEval.override(false);
|
||||
getEvaluator()->paths.allowedPaths.reset();
|
||||
}
|
||||
|
||||
auto evaluator = getEvaluator();
|
||||
auto vFile = evaluator->mem.allocValue();
|
||||
|
||||
|
||||
@@ -33,3 +33,6 @@ simpleTest 'builtins.currentSystem' 'bar' --eval-system 'bar'
|
||||
## `eval-system` overrides `system`
|
||||
simpleTest 'builtins.currentSystem' 'bar' --system 'foo' --eval-system 'bar'
|
||||
simpleTest 'builtins.currentSystem' 'baz' --system 'foo' --eval-system 'baz'
|
||||
|
||||
## `-f` honors nix-path
|
||||
[ "$(nix eval --option nix-path "foo=$PWD" -f '<foo/eval.nix>' attr.foo)" = '"bar"' ]
|
||||
|
||||
Reference in New Issue
Block a user