at 23.11-beta 98 lines 3.3 kB view raw
1{ supportedSystems, nixpkgs, pkgs, nix }: 2 3pkgs.runCommand "nixpkgs-release-checks" 4 { 5 src = nixpkgs; 6 buildInputs = [ nix ]; 7 requiredSystemFeatures = [ "big-parallel" ]; # 1 thread but ~10G RAM; see #227945 8 } 9 '' 10 set -o pipefail 11 12 export NIX_STORE_DIR=$TMPDIR/store 13 export NIX_STATE_DIR=$TMPDIR/state 14 export NIX_PATH=nixpkgs=$TMPDIR/barf.nix 15 opts=(--option build-users-group "") 16 nix-store --init 17 18 echo 'abort "Illegal use of <nixpkgs> in Nixpkgs."' > $TMPDIR/barf.nix 19 20 # Make sure that Nixpkgs does not use <nixpkgs>. 21 badFiles=$(find $src/pkgs -type f -name '*.nix' -print | xargs grep -l '^[^#]*<nixpkgs\/' || true) 22 if [[ -n $badFiles ]]; then 23 echo "Nixpkgs is not allowed to use <nixpkgs> to refer to itself." 24 echo "The offending files: $badFiles" 25 exit 1 26 fi 27 28 # Make sure that no paths collide on case-preserving or case-insensitive filesysytems. 29 conflictingPaths=$(find $src | awk '{ print $1 " " tolower($1) }' | sort -k2 | uniq -D -f 1 | cut -d ' ' -f 1) 30 if [[ -n $conflictingPaths ]]; then 31 echo "Files in nixpkgs must not vary only by case" 32 echo "The offending paths: $conflictingPaths" 33 exit 1 34 fi 35 36 src2=$TMPDIR/foo 37 cp -rd $src $src2 38 39 # Check that all-packages.nix evaluates on a number of platforms without any warnings. 40 for platform in ${pkgs.lib.concatStringsSep " " supportedSystems}; do 41 echo "checking Nixpkgs on $platform" 42 43 # To get a call trace; see https://nixos.org/manual/nixpkgs/stable/#function-library-lib.trivial.warn 44 # Relies on impure eval 45 export NIX_ABORT_ON_WARN=true 46 47 set +e 48 ( 49 set -x 50 nix-env -f $src \ 51 --show-trace --argstr system "$platform" \ 52 --arg config '{ allowAliases = false; }' \ 53 --option experimental-features 'no-url-literals' \ 54 -qa --drv-path --system-filter \* --system \ 55 "''${opts[@]}" 2> eval-warnings.log > packages1 56 ) 57 rc=$? 58 set -e 59 if [ "$rc" != "0" ]; then 60 cat eval-warnings.log 61 exit $rc 62 fi 63 64 s1=$(sha1sum packages1 | cut -c1-40) 65 echo $s1 66 67 nix-env -f $src2 \ 68 --show-trace --argstr system "$platform" \ 69 --arg config '{ allowAliases = false; }' \ 70 --option experimental-features 'no-url-literals' \ 71 -qa --drv-path --system-filter \* --system \ 72 "''${opts[@]}" > packages2 73 74 s2=$(sha1sum packages2 | cut -c1-40) 75 76 if [[ $s1 != $s2 ]]; then 77 echo "Nixpkgs evaluation depends on Nixpkgs path" 78 diff packages1 packages2 79 exit 1 80 fi 81 82 # Catch any trace calls not caught by NIX_ABORT_ON_WARN (lib.warn) 83 if [ -s eval-warnings.log ]; then 84 echo "Nixpkgs on $platform evaluated with warnings, aborting" 85 exit 1 86 fi 87 rm eval-warnings.log 88 89 nix-env -f $src \ 90 --show-trace --argstr system "$platform" \ 91 --arg config '{ allowAliases = false; }' \ 92 --option experimental-features 'no-url-literals' \ 93 -qa --drv-path --system-filter \* --system --meta --xml \ 94 "''${opts[@]}" > /dev/null 95 done 96 97 touch $out 98''