about summary refs log tree commit diff
path: root/src/nix/eval.cc
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2018-01-17T11·03+0100
committerEelco Dolstra <edolstra@gmail.com>2018-01-17T11·03+0100
commit16e0287556cbf04d2642c1091b4fe00fa6e352af (patch)
treea59cdf94ce67d45ca50fdb45a0521498fb68a12d /src/nix/eval.cc
parentcfeff3b2731fd7e6dd030d4e4d56ff3a3aeac903 (diff)
nix eval: Take only one argument
Thus --json no longer produces a list.
Diffstat (limited to 'src/nix/eval.cc')
-rw-r--r--src/nix/eval.cc26
1 files changed, 11 insertions, 15 deletions
diff --git a/src/nix/eval.cc b/src/nix/eval.cc
index 0fbeca1c121d..2bc58b7dd4b5 100644
--- a/src/nix/eval.cc
+++ b/src/nix/eval.cc
@@ -8,7 +8,7 @@
 
 using namespace nix;
 
-struct CmdEval : MixJSON, InstallablesCommand
+struct CmdEval : MixJSON, InstallableCommand
 {
     bool raw = false;
 
@@ -56,20 +56,16 @@ struct CmdEval : MixJSON, InstallablesCommand
 
         auto state = getEvalState();
 
-        auto jsonOut = json ? std::make_unique<JSONList>(std::cout) : nullptr;
-
-        for (auto & i : installables) {
-            auto v = i->toValue(*state);
-            PathSet context;
-            if (raw) {
-                std::cout << state->coerceToString(noPos, *v, context);
-            } else if (json) {
-                auto jsonElem = jsonOut->placeholder();
-                printValueAsJSON(*state, true, *v, jsonElem, context);
-            } else {
-                state->forceValueDeep(*v);
-                std::cout << *v << "\n";
-            }
+        auto v = installable->toValue(*state);
+        PathSet context;
+        if (raw) {
+            std::cout << state->coerceToString(noPos, *v, context);
+        } else if (json) {
+            JSONPlaceholder jsonOut(std::cout);
+            printValueAsJSON(*state, true, *v, jsonOut, context);
+        } else {
+            state->forceValueDeep(*v);
+            std::cout << *v << "\n";
         }
     }
 };