2017-10-25 14:35:45 +01: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".
|
|
|
|
|
2018-02-08 12:56:54 +00:00
|
|
|
{ stdenv, coreutils, jq }:
|
2017-10-25 14:35:45 +01:00
|
|
|
|
|
|
|
{ rootPaths }:
|
|
|
|
|
2018-02-07 14:47:19 +00:00
|
|
|
assert builtins.langVersion >= 5;
|
2017-10-25 14:35:45 +01:00
|
|
|
|
2018-02-07 14:47:19 +00:00
|
|
|
stdenv.mkDerivation {
|
|
|
|
name = "closure-info";
|
2017-10-25 14:35:45 +01:00
|
|
|
|
2018-02-07 14:47:19 +00:00
|
|
|
__structuredAttrs = true;
|
2017-10-25 14:35:45 +01:00
|
|
|
|
2018-02-07 14:47:19 +00:00
|
|
|
exportReferencesGraph.closure = rootPaths;
|
2017-10-25 14:35:45 +01:00
|
|
|
|
2018-02-07 14:47:19 +00:00
|
|
|
PATH = "${coreutils}/bin:${jq}/bin";
|
2017-10-25 14:35:45 +01:00
|
|
|
|
2018-02-07 14:47:19 +00:00
|
|
|
builder = builtins.toFile "builder"
|
|
|
|
''
|
2018-02-27 18:59:26 +00:00
|
|
|
. .attrs.sh
|
2017-10-25 14:35:45 +01:00
|
|
|
|
2018-02-07 14:47:19 +00:00
|
|
|
out=''${outputs[out]}
|
2017-10-25 14:35:45 +01:00
|
|
|
|
2018-02-07 14:47:19 +00:00
|
|
|
mkdir $out
|
2017-10-25 14:35:45 +01: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
|
|
|
|
'';
|
|
|
|
}
|