1{
2 lib,
3 nix,
4 nixpkgs-vet,
5 runCommand,
6}:
7{
8 base ? ../.,
9 head ? ../.,
10}:
11let
12 filtered =
13 with lib.fileset;
14 path:
15 toSource {
16 fileset = difference (gitTracked path) (unions [
17 (path + /.github)
18 (path + /ci)
19 ]);
20 root = path;
21 };
22
23 filteredBase = filtered base;
24 filteredHead = filtered head;
25in
26runCommand "nixpkgs-vet"
27 {
28 nativeBuildInputs = [
29 nixpkgs-vet
30 ];
31 env.NIXPKGS_VET_NIX_PACKAGE = nix;
32 }
33 ''
34 export NIX_STATE_DIR=$(mktemp -d)
35
36 nixpkgs-vet --base ${filteredBase} ${filteredHead}
37
38 # TODO: Upstream into nixpkgs-vet, see:
39 # https://github.com/NixOS/nixpkgs-vet/issues/164
40 badFiles=$(find ${filteredHead}/pkgs -type f -name '*.nix' -print | xargs grep -l '^[^#]*<nixpkgs/' || true)
41 if [[ -n $badFiles ]]; then
42 echo "Nixpkgs is not allowed to use <nixpkgs> to refer to itself."
43 echo "The offending files:"
44 echo "$badFiles"
45 exit 1
46 fi
47
48 # TODO: Upstream into nixpkgs-vet, see:
49 # https://github.com/NixOS/nixpkgs-vet/issues/166
50 conflictingPaths=$(find ${filteredHead} | awk '{ print $1 " " tolower($1) }' | sort -k2 | uniq -D -f 1 | cut -d ' ' -f 1)
51 if [[ -n $conflictingPaths ]]; then
52 echo "Files in nixpkgs must not vary only by case."
53 echo "The offending paths:"
54 echo "$conflictingPaths"
55 exit 1
56 fi
57
58 touch $out
59 ''