From a50c77cc3382b9c9d20a318e40b42a9494eb5efb Mon Sep 17 00:00:00 2001 From: Eman Resu <78693624+quatquatt@users.noreply.github.com> Date: Tue, 19 May 2026 20:45:42 -0400 Subject: [PATCH 1/2] lib.extendMkDerivation: use a single attrset instead of merging --- lib/customisation.nix | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/lib/customisation.nix b/lib/customisation.nix index e9e88aff7cb5..90b6c489785d 100644 --- a/lib/customisation.nix +++ b/lib/customisation.nix @@ -858,24 +858,22 @@ rec { inheritFunctionArgs ? true, transformDrv ? id, }: - setFunctionArgs + { # Adds the fixed-point style support - ( + __functor = + self: fpargs: transformDrv ( constructDrv (extendsWithExclusion excludeDrvArgNames extendDrvArgs (toFunction fpargs)) - ) - ) - # Add __functionArgs - ( - removeAttrs ( - # Inherit the __functionArgs from the base build helper - optionalAttrs inheritFunctionArgs (removeAttrs (functionArgs constructDrv) excludeDrvArgNames) - # Recover the __functionArgs from the derived build helper - // functionArgs (extendDrvArgs { }) - ) excludeFunctionArgNames - ) - // { + ); + + __functionArgs = removeAttrs ( + # Inherit the __functionArgs from the base build helper + optionalAttrs inheritFunctionArgs (removeAttrs (functionArgs constructDrv) excludeDrvArgNames) + # Recover the __functionArgs from the derived build helper + // functionArgs (extendDrvArgs { }) + ) excludeFunctionArgNames; + inherit # Expose to the result build helper. constructDrv From 01272740d899926392fd854bae0cbd67aa5d6bfc Mon Sep 17 00:00:00 2001 From: Eman Resu <78693624+quatquatt@users.noreply.github.com> Date: Tue, 19 May 2026 20:59:24 -0400 Subject: [PATCH 2/2] lib.extendMkDerivation: save several function calls --- lib/customisation.nix | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/lib/customisation.nix b/lib/customisation.nix index 90b6c489785d..d025b0bcea46 100644 --- a/lib/customisation.nix +++ b/lib/customisation.nix @@ -30,7 +30,6 @@ let flatten deepSeq extends - toFunction id ; inherit (lib.strings) levenshtein levenshteinAtMost; @@ -842,14 +841,6 @@ rec { ::: */ extendMkDerivation = - let - extendsWithExclusion = - excludedNames: g: f: final: - let - previous = f final; - in - removeAttrs previous excludedNames // g final previous; - in { constructDrv, excludeDrvArgNames ? [ ], @@ -861,10 +852,15 @@ rec { { # Adds the fixed-point style support __functor = - self: - fpargs: + self: fpargs: transformDrv ( - constructDrv (extendsWithExclusion excludeDrvArgNames extendDrvArgs (toFunction fpargs)) + constructDrv ( + final: + let + previous = if isFunction fpargs then fpargs final else fpargs; + in + removeAttrs previous excludeDrvArgNames // extendDrvArgs final previous + ) ); __functionArgs = removeAttrs (