Skip to content

Commit

Permalink
Add check 'duplicate-check-inputs'
Browse files Browse the repository at this point in the history
  • Loading branch information
rmcgibbo committed Jan 26, 2021
1 parent bbfb319 commit 101e4b0
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 0 deletions.
33 changes: 33 additions & 0 deletions overlays/duplicate-check-inputs.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{ builtAttrs
, packageSet
, namePositions
}@attrs:

final: prev:
let
inherit (prev) lib;
inherit (import ../lib { inherit lib; }) checkFor;

checkDerivation = drvArgs: drv:
let
list1 = drvArgs.propagatedBuildInputs or [];
list2 = drvArgs.checkInputs or [];
intersection = lib.intersectLists list1 list2;
in
lib.singleton {
name = "duplicate-check-inputs";
cond = builtins.length intersection > 0;
msg = ''
Dependencies listed in propagatedBuildInputs shouldn't be repeated in checkInputs.
Detected duplicates:
${lib.concatStringsSep ",\n " (map (d: d.name) intersection)}
'';
locations = [
(builtins.unsafeGetAttrPos "checkInputs" drvArgs)
(builtins.unsafeGetAttrPos "propagatedBuildInputs" drvArgs)
];
};
in
checkFor checkDerivation attrs final prev
4 changes: 4 additions & 0 deletions run-tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ def __iter__(self):
],
)

yield make_test_rule(
'duplicate-check-inputs',
)

yield make_test_rule(
'explicit-phases',
[
Expand Down
1 change: 1 addition & 0 deletions tests/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
{
attribute-ordering = pkgs.callPackage ./attribute-ordering { };
build-tools-in-build-inputs = pkgs.recurseIntoAttrs (pkgs.callPackage ./build-tools-in-build-inputs { });
duplicate-check-inputs = pkgs.python3.pkgs.callPackage ./duplicate-check-inputs { };
explicit-phases = pkgs.callPackage ./explicit-phases { };
fixup-phase = pkgs.callPackage ./fixup-phase { };
meson-cmake = pkgs.callPackage ./meson-cmake { };
Expand Down
12 changes: 12 additions & 0 deletions tests/duplicate-check-inputs/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{ buildPythonPackage
, numpy
}:

buildPythonPackage {
pname = "patch-phase";

src = ../fixtures/make;

propagatedBuildInputs = [ numpy ];
checkInputs = [ numpy ];
}

0 comments on commit 101e4b0

Please sign in to comment.