aboutsummaryrefslogtreecommitdiff
path: root/src/libstore/build.cc
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2017-01-26 20:36:20 +0100
committerEelco Dolstra <edolstra@gmail.com>2017-01-26 20:41:08 +0100
commitc2b0d8749f7e77afc1c4b3e8dd36b7ee9720af4a (patch)
tree7f3c6b2eba4e0d7a82d5f281299d1cecd189c20c /src/libstore/build.cc
parent6de33a9c675b187437a2e1abbcb290981a89ecb1 (diff)
exportReferencesGraph: Export more complete info in JSON format
This writes info about every path in the closure in the same format as ‘nix path-info --json’. Thus it also includes NAR hashes and sizes. Example: [ { "path": "/nix/store/10h6li26i7g6z3mdpvra09yyf10mmzdr-hello-2.10", "narHash": "sha256:0ckdc4z20kkmpqdilx0wl6cricxv90lh85xpv2qljppcmz6vzcxl", "narSize": 197648, "references": [ "/nix/store/10h6li26i7g6z3mdpvra09yyf10mmzdr-hello-2.10", "/nix/store/27binbdy296qvjycdgr1535v8872vz3z-glibc-2.24" ], "closureSize": 20939776 }, { "path": "/nix/store/27binbdy296qvjycdgr1535v8872vz3z-glibc-2.24", "narHash": "sha256:1nfn3m3p98y1c0kd0brp80dn9n5mycwgrk183j17rajya0h7gax3", "narSize": 20742128, "references": [ "/nix/store/27binbdy296qvjycdgr1535v8872vz3z-glibc-2.24" ], "closureSize": 20742128 } ] Fixes #1134.
Diffstat (limited to 'src/libstore/build.cc')
-rw-r--r--src/libstore/build.cc12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/libstore/build.cc b/src/libstore/build.cc
index d76c8d172..7fb5271f4 100644
--- a/src/libstore/build.cc
+++ b/src/libstore/build.cc
@@ -10,6 +10,7 @@
#include "builtins.hh"
#include "finally.hh"
#include "compression.hh"
+#include "json.hh"
#include <algorithm>
#include <iostream>
@@ -2273,9 +2274,18 @@ void DerivationGoal::doExportReferencesGraph()
}
}
- /* Write closure info to `fileName'. */
+ /* Write closure info to <fileName>. */
writeFile(tmpDir + "/" + fileName,
worker.store.makeValidityRegistration(paths, false, false));
+
+ /* Write a more comprehensive JSON serialisation to
+ <fileName>.json. */
+ std::ostringstream str;
+ {
+ JSONPlaceholder jsonRoot(str, true);
+ worker.store.pathInfoToJSON(jsonRoot, paths, false, true);
+ }
+ writeFile(tmpDir + "/" + fileName + ".json", str.str());
}
}