1 { supportedSystems, nixpkgs, pkgs, nix }:
3 pkgs.runCommand "nixpkgs-release-checks" { src = nixpkgs; buildInputs = [nix]; } ''
6 export NIX_STORE_DIR=$TMPDIR/store
7 export NIX_STATE_DIR=$TMPDIR/state
8 export NIX_PATH=nixpkgs=$TMPDIR/barf.nix
9 opts=(--option build-users-group "")
12 echo 'abort "Illegal use of <nixpkgs> in Nixpkgs."' > $TMPDIR/barf.nix
14 # Make sure that Nixpkgs does not use <nixpkgs>.
15 badFiles=$(find $src/pkgs -type f -name '*.nix' -print | xargs grep -l '^[^#]*<nixpkgs\/' || true)
16 if [[ -n $badFiles ]]; then
17 echo "Nixpkgs is not allowed to use <nixpkgs> to refer to itself."
18 echo "The offending files: $badFiles"
22 # Make sure that no paths collide on case-preserving or case-insensitive filesysytems.
23 conflictingPaths=$(find $src | awk '{ print $1 " " tolower($1) }' | sort -k2 | uniq -D -f 1 | cut -d ' ' -f 1)
24 if [[ -n $conflictingPaths ]]; then
25 echo "Files in nixpkgs must not vary only by case"
26 echo "The offending paths: $conflictingPaths"
33 # Check that all-packages.nix evaluates on a number of platforms without any warnings.
34 for platform in ${pkgs.lib.concatStringsSep " " supportedSystems}; do
35 header "checking Nixpkgs on $platform"
37 # To get a call trace; see https://nixos.org/manual/nixpkgs/stable/#function-library-lib.trivial.warn
38 # Relies on impure eval
39 export NIX_ABORT_ON_WARN=true
45 --show-trace --argstr system "$platform" \
46 --arg config '{ allowAliases = false; }' \
47 --option experimental-features 'no-url-literals' \
48 -qa --drv-path --system-filter \* --system \
49 "''${opts[@]}" 2> eval-warnings.log > packages1
53 if [ "$rc" != "0" ]; then
58 s1=$(sha1sum packages1 | cut -c1-40)
62 --show-trace --argstr system "$platform" \
63 --arg config '{ allowAliases = false; }' \
64 --option experimental-features 'no-url-literals' \
65 -qa --drv-path --system-filter \* --system \
66 "''${opts[@]}" > packages2
68 s2=$(sha1sum packages2 | cut -c1-40)
70 if [[ $s1 != $s2 ]]; then
71 echo "Nixpkgs evaluation depends on Nixpkgs path"
72 diff packages1 packages2
76 # Catch any trace calls not caught by NIX_ABORT_ON_WARN (lib.warn)
77 if [ -s eval-warnings.log ]; then
78 echo "Nixpkgs on $platform evaluated with warnings, aborting"
84 --show-trace --argstr system "$platform" \
85 --arg config '{ allowAliases = false; }' \
86 --option experimental-features 'no-url-literals' \
87 -qa --drv-path --system-filter \* --system --meta --xml \
88 "''${opts[@]}" > /dev/null