summary refs log tree commit diff
path: root/pkgs/build-support
diff options
context:
space:
mode:
authorLinus Heckemann <git@sphalerite.org>2023-11-04 09:54:41 +0100
committerLinus Heckemann <git@sphalerite.org>2023-11-04 09:54:41 +0100
commitbdd23d10b25840d8336af1f7958d4cc7d1868098 (patch)
tree0f7f30e0f1b3437638c5cbf86b1fd5e8b7118cc2 /pkgs/build-support
parent10d3ba75f063027a0019756d785be9e91a6f0c04 (diff)
downloadnixpkgs-bdd23d10b25840d8336af1f7958d4cc7d1868098.tar
nixpkgs-bdd23d10b25840d8336af1f7958d4cc7d1868098.tar.gz
nixpkgs-bdd23d10b25840d8336af1f7958d4cc7d1868098.tar.bz2
nixpkgs-bdd23d10b25840d8336af1f7958d4cc7d1868098.tar.lz
nixpkgs-bdd23d10b25840d8336af1f7958d4cc7d1868098.tar.xz
nixpkgs-bdd23d10b25840d8336af1f7958d4cc7d1868098.tar.zst
nixpkgs-bdd23d10b25840d8336af1f7958d4cc7d1868098.zip
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.
Diffstat (limited to 'pkgs/build-support')
-rw-r--r--pkgs/build-support/closure-info.nix14
1 files changed, 11 insertions, 3 deletions
diff --git a/pkgs/build-support/closure-info.nix b/pkgs/build-support/closure-info.nix
index f6c31bd786b..f2aa4964d9a 100644
--- a/pkgs/build-support/closure-info.nix
+++ b/pkgs/build-support/closure-info.nix
@@ -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
+
     '';
 }