From 1e022acbf5861841e47e8fbac78fb483dc488e94 Mon Sep 17 00:00:00 2001 From: Eman Resu <78693624+quatquatt@users.noreply.github.com> Date: Sun, 26 Apr 2026 15:41:33 -0400 Subject: [PATCH] lib.makeOverridable: inline several variables --- lib/customisation.nix | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/lib/customisation.nix b/lib/customisation.nix index d6a1eb8d9bab..fdaf80c9b6b8 100644 --- a/lib/customisation.nix +++ b/lib/customisation.nix @@ -159,28 +159,28 @@ rec { # When f is a callable attribute set, # it may contain its own `f.override` and additional attributes. # This helper function recovers those attributes and decorate the overrider. - recoverMetadata = + decorate = + f': if isAttrs f then - fDecorated: - # Preserve additional attributes for f - f - // fDecorated - # Decorate f.override if presented - // lib.optionalAttrs (f ? override) { - override = fdrv: makeOverridable (f.override fdrv); - } + ( + fDecorated: + # Preserve additional attributes for f + f + // fDecorated + # Decorate f.override if presented + // lib.optionalAttrs (f ? override) { + override = fdrv: makeOverridable (f.override fdrv); + } + ) + (mirrorArgs f') else - id; - decorate = f': recoverMetadata (mirrorArgs f'); + mirrorArgs f'; in decorate ( origArgs: let result = f origArgs; - # Changes the original arguments with (potentially a function that returns) a set of new attributes - overrideWith = newArgs: origArgs // (if isFunction newArgs then newArgs origArgs else newArgs); - # Re-call the function but with different arguments overrideArgs = mirrorArgs ( /** @@ -190,7 +190,7 @@ rec { This function was provided by `lib.makeOverridable`. */ - newArgs: makeOverridable f (overrideWith newArgs) + newArgs: makeOverridable f (origArgs // (if isFunction newArgs then newArgs origArgs else newArgs)) ); # Change the result of the function call by applying g to it overrideResult = g: makeOverridable (mirrorArgs (args: g (f args))) origArgs;