2017-10-25 13:35:45 +00:00
|
|
|
# This derivation builds two files containing information about the
|
|
|
|
# closure of 'rootPaths': $out/store-paths contains the paths in the
|
|
|
|
# closure, and $out/registration contains a file suitable for use with
|
|
|
|
# "nix-store --load-db" and "nix-store --register-validity
|
|
|
|
# --hash-given".
|
|
|
|
|
|
|
|
{ stdenv, coreutils, jq, perl, pathsFromGraph }:
|
|
|
|
|
|
|
|
{ rootPaths }:
|
|
|
|
|
2018-02-07 14:47:19 +00:00
|
|
|
assert builtins.langVersion >= 5;
|
2017-10-25 13:35:45 +00:00
|
|
|
|
2018-02-07 14:47:19 +00:00
|
|
|
stdenv.mkDerivation {
|
|
|
|
name = "closure-info";
|
2017-10-25 13:35:45 +00:00
|
|
|
|
2018-02-07 14:47:19 +00:00
|
|
|
__structuredAttrs = true;
|
2017-10-25 13:35:45 +00:00
|
|
|
|
2018-02-07 14:47:19 +00:00
|
|
|
exportReferencesGraph.closure = rootPaths;
|
2017-10-25 13:35:45 +00:00
|
|
|
|
2018-02-07 14:47:19 +00:00
|
|
|
PATH = "${coreutils}/bin:${jq}/bin";
|
2017-10-25 13:35:45 +00:00
|
|
|
|
2018-02-07 14:47:19 +00:00
|
|
|
builder = builtins.toFile "builder"
|
|
|
|
''
|
|
|
|
if [ -e .attrs.sh ]; then . .attrs.sh; fi
|
2017-10-25 13:35:45 +00:00
|
|
|
|
2018-02-07 14:47:19 +00:00
|
|
|
out=''${outputs[out]}
|
2017-10-25 13:35:45 +00:00
|
|
|
|
2018-02-07 14:47:19 +00:00
|
|
|
mkdir $out
|
2017-10-25 13:35:45 +00:00
|
|
|
|
2018-02-23 15:52:37 +00:00
|
|
|
jq -r ".closure | map(.narSize) | add" < .attrs.json > $out/total-nar-size
|
2018-02-07 14:47:19 +00:00
|
|
|
jq -r '.closure | map([.path, .narHash, .narSize, "", (.references | length)] + .references) | add | map("\(.)\n") | add' < .attrs.json | head -n -1 > $out/registration
|
|
|
|
jq -r .closure[].path < .attrs.json > $out/store-paths
|
|
|
|
'';
|
|
|
|
}
|