about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2014-06-02T15·58+0200
committerEelco Dolstra <eelco.dolstra@logicblox.com>2014-06-02T15·58+0200
commit3c6b8a521561f5341652ffe37b869d5ab457227b (patch)
treeb646f7227bb180564e411734e07c569545e1d41e /src
parentceed8192848760430c9c23659f9cb979aad1f9c3 (diff)
nix-env -qa --json: Generate valid JSON even if there are invalid meta attrs
Diffstat (limited to 'src')
-rw-r--r--src/nix-env/nix-env.cc5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/nix-env/nix-env.cc b/src/nix-env/nix-env.cc
index 2d38f2aea729..05f6aa354997 100644
--- a/src/nix-env/nix-env.cc
+++ b/src/nix-env/nix-env.cc
@@ -882,9 +882,10 @@ static void queryJSON(Globals & globals, vector<DrvInfo> & elems)
         foreach (StringSet::iterator, j, metaNames) {
             metaObj.attr(*j);
             Value * v = i->queryMeta(*j);
-            if (!v)
+            if (!v) {
                 printMsg(lvlError, format("derivation `%1%' has invalid meta attribute `%2%'") % i->name % *j);
-            else {
+                cout << "null";
+            } else {
                 PathSet context;
                 printValueAsJSON(globals.state, true, *v, cout, context);
             }