Commit ee6b0bda authored by K900's avatar K900
Browse files

pkgs/top-level/make-tarball.nix: add back the number of packages sanity check

But in a way that's fast.
parent 4a0c2fa8
Loading
Loading
Loading
Loading
+10 −3
Original line number Diff line number Diff line
@@ -34,13 +34,20 @@ pkgs.releaseTools.sourceTarball {
  checkPhase = ''
    echo "generating packages.json"

    packages=$out/packages.json.br

    (
      echo -n '{"version":2,"packages":'
      NIX_STATE_DIR=$TMPDIR NIX_PATH= nix-env -f $src -qa --meta --json --show-trace --arg config 'import ${./packages-config.nix}'
      echo -n '}'
    ) | sed "s|$src/||g" | jq -c | brotli -9 > $packages
    ) | sed "s|$src/||g" | jq -c > packages.json

    # Arbitrary number. The index has ~115k packages as of April 2024.
    if [ $(jq -r '.packages | length' < packages.json) -lt 100000 ]; then
      echo "ERROR: not enough packages in the search index, bailing out!"
      exit 1
    fi

    packages=$out/packages.json.br
    brotli -9 < packages.json > $packages

    mkdir -p $out/nix-support
    echo "file json-br $packages" >> $out/nix-support/hydra-build-products