closureInfo: handle empty path set explicitly

Arguably, this is a bug in Nix's structuredAttrs: without
structuredAttrs, exportReferencesGraph with an empty path set would
still result in information being provided. With structuredAttrs, no
info is provided for an empty path set.

Nevertheless, we need to be able to build even if Nix has the bug, so
work around it by checking for an empty path set and handling it
explicitly.

+11 -3
+11 -3
pkgs/build-support/closure-info.nix
··· 21 22 nativeBuildInputs = [ coreutils jq ]; 23 24 buildCommand = 25 '' 26 out=''${outputs[out]} 27 28 mkdir $out 29 30 - jq -r ".closure | map(.narSize) | add" < "$NIX_ATTRS_JSON_FILE" > $out/total-nar-size 31 - jq -r '.closure | map([.path, .narHash, .narSize, "", (.references | length)] + .references) | add | map("\(.)\n") | add' < "$NIX_ATTRS_JSON_FILE" | head -n -1 > $out/registration 32 - jq -r '.closure[].path' < "$NIX_ATTRS_JSON_FILE" > $out/store-paths 33 ''; 34 }
··· 21 22 nativeBuildInputs = [ coreutils jq ]; 23 24 + empty = rootPaths == []; 25 + 26 buildCommand = 27 '' 28 out=''${outputs[out]} 29 30 mkdir $out 31 32 + if [[ -n "$empty" ]]; then 33 + echo 0 > $out/total-nar-size 34 + touch $out/registration $out/store-paths 35 + else 36 + jq -r ".closure | map(.narSize) | add" < "$NIX_ATTRS_JSON_FILE" > $out/total-nar-size 37 + jq -r '.closure | map([.path, .narHash, .narSize, "", (.references | length)] + .references) | add | map("\(.)\n") | add' < "$NIX_ATTRS_JSON_FILE" | head -n -1 > $out/registration 38 + jq -r '.closure[].path' < "$NIX_ATTRS_JSON_FILE" > $out/store-paths 39 + fi 40 + 41 ''; 42 }