From 9f6461221530d0336d159bf5e8509c31b798ea68 Mon Sep 17 00:00:00 2001 From: Zhaofeng Li Date: Wed, 17 Aug 2022 00:38:37 -0600 Subject: [PATCH] Don't override evalSettings.pureEval unless necessary Other eval flags like `--pure-eval` may activate `evalSettings.pureEval`, so let's avoid touching it if we don't have to. --- src/nix-eval-jobs.cc | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/src/nix-eval-jobs.cc b/src/nix-eval-jobs.cc index eb97d0b..dac8532 100644 --- a/src/nix-eval-jobs.cc +++ b/src/nix-eval-jobs.cc @@ -30,8 +30,6 @@ using namespace nix; using namespace nlohmann; -typedef enum { evalAuto, evalImpure, evalPure } pureEval; - // Safe to ignore - the args will be static. #ifdef __GNUC__ #pragma GCC diagnostic ignored "-Wnon-virtual-dtor" @@ -44,9 +42,9 @@ struct MyArgs : MixEvalArgs, MixCommonArgs { bool flake = false; bool meta = false; bool showTrace = false; + bool impure = false; size_t nrWorkers = 1; size_t maxMemorySize = 4096; - pureEval evalMode = evalAuto; MyArgs() : MixCommonArgs("nix-eval-jobs") { addFlag({ @@ -65,11 +63,9 @@ struct MyArgs : MixEvalArgs, MixCommonArgs { }}, }); - addFlag({ - .longName = "impure", - .description = "set evaluation mode", - .handler = {[&]() { evalMode = evalImpure; }}, - }); + addFlag({.longName = "impure", + .description = "allow impure expressions", + .handler = {&impure, true}}); addFlag({.longName = "gc-roots-dir", .description = "garbage collector roots directory", @@ -493,9 +489,11 @@ int main(int argc, char **argv) { /* When building a flake, use pure evaluation (no access to 'getEnv', 'currentSystem' etc. */ - evalSettings.pureEval = myArgs.evalMode == evalAuto - ? myArgs.flake - : myArgs.evalMode == evalPure; + if (myArgs.impure) { + evalSettings.pureEval = false; + } else if (myArgs.flake) { + evalSettings.pureEval = true; + } if (myArgs.releaseExpr == "") throw UsageError("no expression specified");