mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-26 00:43:20 +00:00
lib/makeOverridable: Deduplicate override definition
And call it overrideArgs in the let binding because that's what it does
This commit is contained in:
parent
a41af6a27b
commit
a75080f58c
@ -68,16 +68,19 @@ rec {
|
|||||||
let
|
let
|
||||||
ff = f origArgs;
|
ff = f origArgs;
|
||||||
overrideWith = newArgs: origArgs // (if lib.isFunction newArgs then newArgs origArgs else newArgs);
|
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
|
in
|
||||||
if builtins.isAttrs ff then (ff // {
|
if builtins.isAttrs ff then (ff // {
|
||||||
override = newArgs: makeOverridable f (overrideWith newArgs);
|
override = overrideArgs;
|
||||||
overrideDerivation = fdrv:
|
overrideDerivation = fdrv:
|
||||||
makeOverridable (args: overrideDerivation (f args) fdrv) origArgs;
|
makeOverridable (args: overrideDerivation (f args) fdrv) origArgs;
|
||||||
${if ff ? overrideAttrs then "overrideAttrs" else null} = fdrv:
|
${if ff ? overrideAttrs then "overrideAttrs" else null} = fdrv:
|
||||||
makeOverridable (args: (f args).overrideAttrs fdrv) origArgs;
|
makeOverridable (args: (f args).overrideAttrs fdrv) origArgs;
|
||||||
})
|
})
|
||||||
else if lib.isFunction ff then {
|
else if lib.isFunction ff then {
|
||||||
override = newArgs: makeOverridable f (overrideWith newArgs);
|
override = overrideArgs;
|
||||||
__functor = self: ff;
|
__functor = self: ff;
|
||||||
overrideDerivation = throw "overrideDerivation not yet supported for functors";
|
overrideDerivation = throw "overrideDerivation not yet supported for functors";
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user