mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-15 14:26:33 +01:00
6f733a03df
This reverts commit58dd4924b9
, reversing changes made to7da9f66ccb
. This was a mass-rebuild that was not intended to be merged.
42 lines
1.1 KiB
Nix
42 lines
1.1 KiB
Nix
# 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 }:
|
|
|
|
{ rootPaths }:
|
|
|
|
assert builtins.langVersion >= 5;
|
|
|
|
stdenv.mkDerivation {
|
|
name = "closure-info";
|
|
|
|
__structuredAttrs = true;
|
|
|
|
exportReferencesGraph.closure = rootPaths;
|
|
|
|
preferLocalBuild = true;
|
|
|
|
nativeBuildInputs = [ coreutils jq ];
|
|
|
|
empty = rootPaths == [];
|
|
|
|
buildCommand =
|
|
''
|
|
out=''${outputs[out]}
|
|
|
|
mkdir $out
|
|
|
|
if [[ -n "$empty" ]]; then
|
|
echo 0 > $out/total-nar-size
|
|
touch $out/registration $out/store-paths
|
|
else
|
|
jq -r ".closure | map(.narSize) | add" < "$NIX_ATTRS_JSON_FILE" > $out/total-nar-size
|
|
jq -r '.closure | map([.path, .narHash, .narSize, "", (.references | length)] + .references) | add | map("\(.)\n") | add' < "$NIX_ATTRS_JSON_FILE" | head -n -1 > $out/registration
|
|
jq -r '.closure[].path' < "$NIX_ATTRS_JSON_FILE" > $out/store-paths
|
|
fi
|
|
|
|
'';
|
|
}
|