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".
|
|
|
|
|
2019-06-16 20:59:06 +01:00
|
|
|
{ stdenv, buildPackages }:
|
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-11-08 10:59:03 +00:00
|
|
|
preferLocalBuild = true;
|
|
|
|
|
2018-06-30 00:16:39 +01:00
|
|
|
PATH = "${buildPackages.coreutils}/bin:${buildPackages.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
|
|
|
|
'';
|
|
|
|
}
|