3 , pkgs ? import nixpkgs.outPath {}
5 , lib-tests ? import ../../lib/tests/release.nix { inherit pkgs; }
8 pkgs.releaseTools.sourceTarball {
9 name = "nixpkgs-tarball";
12 inherit officialRelease;
13 version = pkgs.lib.fileContents ../../.version;
14 versionSuffix = "pre${
15 if nixpkgs ? lastModified
16 then builtins.substring 0 8 (nixpkgs.lastModifiedDate or nixpkgs.lastModified)
17 else toString (nixpkgs.revCount or 0)}.${nixpkgs.shortRev or "dirty"}";
19 buildInputs = with pkgs; [ nix.out jq lib-tests brotli ];
23 releaseName=nixpkgs-$VERSION$VERSION_SUFFIX
24 echo -n $VERSION_SUFFIX > .version-suffix
25 echo -n ${nixpkgs.rev or nixpkgs.shortRev or "dirty"} > .git-revision
26 echo "release name is $releaseName"
27 echo "git-revision is $(cat .git-revision)"
37 echo "generating packages.json"
40 echo -n '{"version":2,"packages":'
41 NIX_STATE_DIR=$TMPDIR NIX_PATH= nix-env -f $src -qa --meta --json --show-trace --arg config 'import ${./packages-config.nix}'
43 ) | sed "s|$src/||g" | jq -c > packages.json
45 # Arbitrary number. The index has ~115k packages as of April 2024.
46 if [ $(jq -r '.packages | length' < packages.json) -lt 100000 ]; then
47 echo "ERROR: not enough packages in the search index, bailing out!"
51 packages=$out/packages.json.br
53 mkdir -p $out/nix-support
54 brotli -9 < packages.json > $packages
55 echo "file json-br $packages" >> $out/nix-support/hydra-build-products
58 # --hard-dereference: reproducibility for src if auto-optimise-store = true
59 # Some context: https://github.com/NixOS/infra/issues/438
61 mkdir -p $out/tarballs
65 --file=$out/tarballs/$releaseName.tar.xz \
67 --transform="s|^$src|$releaseName|g" \
68 --transform="s|^$(pwd)|$releaseName|g" \
74 --mtime="@$SOURCE_DATE_EPOCH" \
77 $src $(pwd)/{.version-suffix,.git-revision}