0
0
Fork 0
mirror of https://github.com/NixOS/nixpkgs.git synced 2025-07-14 14:10:33 +03:00

lib.makeOverridable: fix functionArgs on returned function

This commit is contained in:
Robert Hensing 2023-10-11 22:56:53 +02:00
parent f6caf65a4a
commit 0a10279342
2 changed files with 16 additions and 3 deletions

View file

@ -69,8 +69,8 @@ rec {
"<pkg>.overrideDerivation" to learn about `overrideDerivation` and caveats "<pkg>.overrideDerivation" to learn about `overrideDerivation` and caveats
related to its use. related to its use.
*/ */
makeOverridable = f: origArgs: makeOverridable = f: lib.setFunctionArgs
let (origArgs: let
result = f origArgs; result = f origArgs;
# Creates a functor with the same arguments as f # Creates a functor with the same arguments as f
@ -95,7 +95,8 @@ rec {
lib.setFunctionArgs result (lib.functionArgs result) // { lib.setFunctionArgs result (lib.functionArgs result) // {
override = overrideArgs; override = overrideArgs;
} }
else result; else result)
(lib.functionArgs f);
/* Call the package function in the file `fn` with the required /* Call the package function in the file `fn` with the required

View file

@ -43,6 +43,18 @@ in
runTests { runTests {
# CUSTOMIZATION
testFunctionArgsMakeOverridable = {
expr = functionArgs (makeOverridable ({ a, b, c ? null}: {}));
expected = { a = false; b = false; c = true; };
};
testFunctionArgsMakeOverridableOverride = {
expr = functionArgs (makeOverridable ({ a, b, c ? null }: {}) { a = 1; b = 2; }).override;
expected = { a = false; b = false; c = true; };
};
# TRIVIAL # TRIVIAL
testId = { testId = {