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 6141217
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,15 @@ rec {
let
originalDrv = originalFunction args;
namePosition = originalDrv.meta.position or null;
resolvedArgs =
if builtins.isFunction args then
# Resolve recursive attributes in mkDerivation
# https://nixos.org/manual/nixpkgs/stable/#mkderivation-recursive-attributes
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 { };
}
13 changes: 13 additions & 0 deletions tests/no-flags-array/make-finalAttrs.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{ stdenv
}:

stdenv.mkDerivation (finalAttrs: {
name = "no-flags-array-make";

src = ../fixtures/make;

makeFlagsArray = [
"PREFIX=${placeholder "out"}"
"LIBDIR=${placeholder "out"}/lib"
];
})

0 comments on commit 6141217

Please sign in to comment.