Skip to content

Commit

Permalink
Merge pull request #265414 from lheckemann/fix-empty-closureInfo
Browse files Browse the repository at this point in the history
closureInfo: handle empty path set explicitly
  • Loading branch information
Ma27 authored Nov 7, 2023
2 parents bed5644 + bdd23d1 commit be31242
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions pkgs/build-support/closure-info.nix
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,22 @@ stdenv.mkDerivation {

nativeBuildInputs = [ coreutils jq ];

empty = rootPaths == [];

buildCommand =
''
out=''${outputs[out]}
mkdir $out
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
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
'';
}

0 comments on commit be31242

Please sign in to comment.