lol
1# This derivation builds two files containing information about the
2# closure of 'rootPaths': $out/store-paths contains the paths in the
3# closure, and $out/registration contains a file suitable for use with
4# "nix-store --load-db" and "nix-store --register-validity
5# --hash-given".
6
7{ stdenv, coreutils, jq }:
8
9{ rootPaths }:
10
11assert builtins.langVersion >= 5;
12
13stdenv.mkDerivation {
14 name = "closure-info";
15
16 __structuredAttrs = true;
17
18 exportReferencesGraph.closure = rootPaths;
19
20 PATH = "${coreutils}/bin:${jq}/bin";
21
22 builder = builtins.toFile "builder"
23 ''
24 . .attrs.sh
25
26 out=''${outputs[out]}
27
28 mkdir $out
29
30 jq -r ".closure | map(.narSize) | add" < .attrs.json > $out/total-nar-size
31 jq -r '.closure | map([.path, .narHash, .narSize, "", (.references | length)] + .references) | add | map("\(.)\n") | add' < .attrs.json | head -n -1 > $out/registration
32 jq -r .closure[].path < .attrs.json > $out/store-paths
33 '';
34}