Skip to content

Commit

Permalink
checkMkDerivationFor: Fix with finalAttrs
Browse files Browse the repository at this point in the history
Fixes: #131
  • Loading branch information
jtojnar committed Nov 4, 2023
1 parent 29fb792 commit 9fbb485
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions run-tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ def __iter__(self):
"no-flags-array",
[
"make",
"make-finalAttrs",
],
)

Expand Down
1 change: 1 addition & 0 deletions tests/no-flags-array/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
{
# positive cases
make = callPackage ./make.nix { };
make-finalAttrs = callPackage ./make-finalAttrs.nix { };
}

0 comments on commit 9fbb485

Please sign in to comment.