1 /* Hydra job to build a tarball for Nixpkgs from a Git checkout. It
2 also builds the documentation and tests whether the Nix expressions
8 , pkgs ? import nixpkgs.outPath {}
10 , lib-tests ? import ../../lib/tests/release.nix { inherit pkgs; }
13 pkgs.releaseTools.sourceTarball {
14 name = "nixpkgs-tarball";
17 inherit officialRelease;
18 version = pkgs.lib.fileContents ../../.version;
19 versionSuffix = "pre${
20 if nixpkgs ? lastModified
21 then builtins.substring 0 8 (nixpkgs.lastModifiedDate or nixpkgs.lastModified)
22 else toString (nixpkgs.revCount or 0)}.${nixpkgs.shortRev or "dirty"}";
24 buildInputs = with pkgs; [ nix.out jq lib-tests brotli ];
28 releaseName=nixpkgs-$VERSION$VERSION_SUFFIX
29 echo -n $VERSION_SUFFIX > .version-suffix
30 echo -n ${nixpkgs.rev or nixpkgs.shortRev or "dirty"} > .git-revision
31 echo "release name is $releaseName"
32 echo "git-revision is $(cat .git-revision)"
35 requiredSystemFeatures = [ "big-parallel" ]; # 1 thread but ~36G RAM (!) see #227945
44 export NIX_STATE_DIR=$TMPDIR
45 export NIX_PATH=nixpkgs=$TMPDIR/barf.nix
46 opts=(--option build-users-group "")
49 echo "checking eval-release.nix"
50 nix-instantiate --eval --strict --show-trace ./maintainers/scripts/eval-release.nix > /dev/null
52 echo "checking find-tarballs.nix"
53 nix-instantiate --readonly-mode --eval --strict --show-trace --json \
54 ./maintainers/scripts/find-tarballs.nix \
55 --arg expr 'import ./maintainers/scripts/all-tarballs.nix' > $TMPDIR/tarballs.json
56 nrUrls=$(jq -r '.[].url' < $TMPDIR/tarballs.json | wc -l)
57 echo "found $nrUrls URLs"
58 if [ "$nrUrls" -lt 10000 ]; then
59 echo "suspiciously low number of URLs"
63 echo "generating packages.json"
64 mkdir -p $out/nix-support
65 echo -n '{"version":2,"packages":' > tmp
66 nix-env -f . -I nixpkgs=$src -qa --meta --json --show-trace --arg config 'import ${./packages-config.nix}' "''${opts[@]}" >> tmp
68 packages=$out/packages.json.br
69 < tmp sed "s|$(pwd)/||g" | jq -c | brotli -9 > $packages
72 echo "file json-br $packages" >> $out/nix-support/hydra-build-products
76 mkdir -p $out/tarballs
78 cp -prd . ../$releaseName
79 (cd .. && tar cfa $out/tarballs/$releaseName.tar.xz $releaseName) || false