lib/makeOverridable: Deduplicate override definition

And call it overrideArgs in the let binding because that's what it does
This commit is contained in:
Silvan Mosberger 2019-09-05 00:06:22 +02:00
parent a41af6a27b
commit a75080f58c
No known key found for this signature in database
GPG Key ID: 9424360B4B85C9E7

View File

@ -68,16 +68,19 @@ rec {
let
ff = f origArgs;
overrideWith = newArgs: origArgs // (if lib.isFunction newArgs then newArgs origArgs else newArgs);
# Re-call the function but with different arguments
overrideArgs = newArgs: makeOverridable f (overrideWith newArgs);
in
if builtins.isAttrs ff then (ff // {
override = newArgs: makeOverridable f (overrideWith newArgs);
override = overrideArgs;
overrideDerivation = fdrv:
makeOverridable (args: overrideDerivation (f args) fdrv) origArgs;
${if ff ? overrideAttrs then "overrideAttrs" else null} = fdrv:
makeOverridable (args: (f args).overrideAttrs fdrv) origArgs;
})
else if lib.isFunction ff then {
override = newArgs: makeOverridable f (overrideWith newArgs);
override = overrideArgs;
__functor = self: ff;
overrideDerivation = throw "overrideDerivation not yet supported for functors";
}