summary refs log tree commit diff
diff options
context:
space:
mode:
authorRobert Hensing <robert@roberthensing.nl>2023-10-11 22:56:53 +0200
committerRobert Hensing <robert@roberthensing.nl>2023-10-11 22:56:53 +0200
commit0a10279342995a40fc4ad08a7f2a8250cc5ef4d7 (patch)
tree0b8090fcff9fdba4b51c79ed1d675dbebd2f9356
parentf6caf65a4a8031f9e1073949734d91b3293034b0 (diff)
downloadnixpkgs-0a10279342995a40fc4ad08a7f2a8250cc5ef4d7.tar
nixpkgs-0a10279342995a40fc4ad08a7f2a8250cc5ef4d7.tar.gz
nixpkgs-0a10279342995a40fc4ad08a7f2a8250cc5ef4d7.tar.bz2
nixpkgs-0a10279342995a40fc4ad08a7f2a8250cc5ef4d7.tar.lz
nixpkgs-0a10279342995a40fc4ad08a7f2a8250cc5ef4d7.tar.xz
nixpkgs-0a10279342995a40fc4ad08a7f2a8250cc5ef4d7.tar.zst
nixpkgs-0a10279342995a40fc4ad08a7f2a8250cc5ef4d7.zip
lib.makeOverridable: fix functionArgs on returned function
-rw-r--r--lib/customisation.nix7
-rw-r--r--lib/tests/misc.nix12
2 files changed, 16 insertions, 3 deletions
diff --git a/lib/customisation.nix b/lib/customisation.nix
index ec2513021f9..5ef4f29e6f6 100644
--- a/lib/customisation.nix
+++ b/lib/customisation.nix
@@ -69,8 +69,8 @@ rec {
      "<pkg>.overrideDerivation" to learn about `overrideDerivation` and caveats
      related to its use.
   */
-  makeOverridable = f: origArgs:
-    let
+  makeOverridable = f: lib.setFunctionArgs
+    (origArgs: let
       result = f origArgs;
 
       # Creates a functor with the same arguments as f
@@ -95,7 +95,8 @@ rec {
         lib.setFunctionArgs result (lib.functionArgs result) // {
           override = overrideArgs;
         }
-      else result;
+      else result)
+    (lib.functionArgs f);
 
 
   /* Call the package function in the file `fn` with the required
diff --git a/lib/tests/misc.nix b/lib/tests/misc.nix
index 6527c31e49c..2e7fda2b1f8 100644
--- a/lib/tests/misc.nix
+++ b/lib/tests/misc.nix
@@ -43,6 +43,18 @@ in
 
 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
 
   testId = {