diff --git a/lib/default.nix b/lib/default.nix index 44d73b4..e410ede 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -58,8 +58,11 @@ rec { let originalDrv = originalFunction args; namePosition = originalDrv.meta.position or null; + # Resolve recursive attributes in mkDerivation + # https://nixos.org/manual/nixpkgs/stable/#mkderivation-recursive-attributes + resolvedArgs = if builtins.isFunction args then (lib.fix (finalAttrs: args finalAttrs // { finalPackage = originalDrv; })) else args; in - addReports originalDrv (check args originalDrv); + addReports originalDrv (check resolvedArgs originalDrv); # Creates an overlay that replaces stdenv.mkDerivation with a function that # checks the attribute set passed as argument to mkDerivation. diff --git a/run-tests.py b/run-tests.py index 9adad09..fe24114 100755 --- a/run-tests.py +++ b/run-tests.py @@ -229,6 +229,7 @@ def __iter__(self): "no-flags-array", [ "make", + "make-finalAttrs", ], ) diff --git a/tests/no-flags-array/default.nix b/tests/no-flags-array/default.nix index 923111c..4b44868 100644 --- a/tests/no-flags-array/default.nix +++ b/tests/no-flags-array/default.nix @@ -4,4 +4,5 @@ { # positive cases make = callPackage ./make.nix { }; + make-finalAttrs = callPackage ./make-finalAttrs.nix { }; }