forked from lix-project/lix
Merge pull request #6027 from Ma27/pure-repl
repl: `--option pure-eval true` actually enables pure eval mode
This commit is contained in:
commit
798efdf10b
|
@ -1039,6 +1039,11 @@ struct CmdRepl : StoreCommand, MixEvalArgs
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool forceImpureByDefault() override
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
std::string description() override
|
std::string description() override
|
||||||
{
|
{
|
||||||
return "start an interactive environment for evaluating Nix expressions";
|
return "start an interactive environment for evaluating Nix expressions";
|
||||||
|
@ -1053,8 +1058,6 @@ struct CmdRepl : StoreCommand, MixEvalArgs
|
||||||
|
|
||||||
void run(ref<Store> store) override
|
void run(ref<Store> store) override
|
||||||
{
|
{
|
||||||
evalSettings.pureEval = false;
|
|
||||||
|
|
||||||
auto evalState = make_ref<EvalState>(searchPath, store);
|
auto evalState = make_ref<EvalState>(searchPath, store);
|
||||||
|
|
||||||
auto repl = std::make_unique<NixRepl>(evalState);
|
auto repl = std::make_unique<NixRepl>(evalState);
|
||||||
|
|
|
@ -25,6 +25,8 @@ public:
|
||||||
/* Return a short one-line description of the command. */
|
/* Return a short one-line description of the command. */
|
||||||
virtual std::string description() { return ""; }
|
virtual std::string description() { return ""; }
|
||||||
|
|
||||||
|
virtual bool forceImpureByDefault() { return false; }
|
||||||
|
|
||||||
/* Return documentation about this command, in Markdown format. */
|
/* Return documentation about this command, in Markdown format. */
|
||||||
virtual std::string doc() { return ""; }
|
virtual std::string doc() { return ""; }
|
||||||
|
|
||||||
|
|
|
@ -380,6 +380,9 @@ void mainWrapped(int argc, char * * argv)
|
||||||
settings.ttlPositiveNarInfoCache = 0;
|
settings.ttlPositiveNarInfoCache = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (args.command->second->forceImpureByDefault() && !evalSettings.pureEval.overridden) {
|
||||||
|
evalSettings.pureEval = false;
|
||||||
|
}
|
||||||
args.command->second->prepare();
|
args.command->second->prepare();
|
||||||
args.command->second->run();
|
args.command->second->run();
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,6 +42,11 @@ testRepl () {
|
||||||
echo "$replOutput"
|
echo "$replOutput"
|
||||||
echo "$replOutput" | grep -qs "while evaluating the file" \
|
echo "$replOutput" | grep -qs "while evaluating the file" \
|
||||||
|| fail "nix repl --show-trace doesn't show the trace"
|
|| fail "nix repl --show-trace doesn't show the trace"
|
||||||
|
|
||||||
|
nix repl "${nixArgs[@]}" --option pure-eval true 2>&1 <<< "builtins.currentSystem" \
|
||||||
|
| grep "attribute 'currentSystem' missing"
|
||||||
|
nix repl "${nixArgs[@]}" 2>&1 <<< "builtins.currentSystem" \
|
||||||
|
| grep "$(nix-instantiate --eval -E 'builtins.currentSystem')"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Simple test, try building a drv
|
# Simple test, try building a drv
|
||||||
|
|
Loading…
Reference in a new issue