Loading pkgs/development/interpreters/python/python-packages-base.nix +16 −2 Original line number Diff line number Diff line Loading @@ -24,10 +24,24 @@ let let result = f origArgs; overrideWith = # Preserve the plain arguments whenever possible, # as `overrideStdenvCompat` works more reliably with `args.stdenv` # than `result.__stdenvPythonCompat`. # TODO(@ShamrockLee): After `overrideStdenvCompat` is fully deprecated, # simplify as # ```nix # newArgs: lib.extends (lib.toExtension newArgs) origArgs # ``` if lib.isFunction origArgs then newArgs: lib.extends (_: lib.toFunction newArgs) origArgs newArgs: lib.extends (lib.toExtension newArgs) origArgs else newArgs: origArgs // lib.toFunction newArgs origArgs; newArgs: if !(lib.isFunction newArgs) then origArgs // newArgs else if !(lib.isFunction (newArgs origArgs)) then origArgs // newArgs origArgs else finalAttrs: origArgs // newArgs finalAttrs origArgs; in if lib.isAttrs result then result Loading pkgs/test/overriding.nix +24 −0 Original line number Diff line number Diff line Loading @@ -434,6 +434,14 @@ let p.overridePythonAttrs (previousAttrs: { overridePythonAttrsFlag = previousAttrs.overridePythonAttrsFlag or 0 + 1; }); applyOverridePythonAttrsFP = p: p.overridePythonAttrs ( finalAttrs: previousAttrs: { overridePythonAttrsFlag = previousAttrs.overridePythonAttrsFlag or 0 + 1; overridePythonAttrsFlagP1 = finalAttrs.overridePythonAttrsFlag + 1; } ); overrideAttrsFooBar = drv: drv.overrideAttrs ( Loading Loading @@ -465,6 +473,22 @@ let expr = (applyOverridePythonAttrs (applyOverridePythonAttrs package-stub)).overridePythonAttrsFlag; expected = 2; }; overridePythonAttrs-plain = { expr = (package-stub.overridePythonAttrs { overridePythonAttrsFlag = 0; }).overridePythonAttrsFlag; expected = 0; }; overridePythonAttrs-finalAttrs = { expr = { inherit (applyOverridePythonAttrsFP package-stub) overridePythonAttrsFlag overridePythonAttrsFlagP1 ; }; expected = { overridePythonAttrsFlag = 1; overridePythonAttrsFlagP1 = 2; }; }; overrideAttrs-overridePythonAttrs-test-overrideAttrs = { expr = { inherit (applyOverridePythonAttrs (overrideAttrsFooBar package-stub)) Loading Loading
pkgs/development/interpreters/python/python-packages-base.nix +16 −2 Original line number Diff line number Diff line Loading @@ -24,10 +24,24 @@ let let result = f origArgs; overrideWith = # Preserve the plain arguments whenever possible, # as `overrideStdenvCompat` works more reliably with `args.stdenv` # than `result.__stdenvPythonCompat`. # TODO(@ShamrockLee): After `overrideStdenvCompat` is fully deprecated, # simplify as # ```nix # newArgs: lib.extends (lib.toExtension newArgs) origArgs # ``` if lib.isFunction origArgs then newArgs: lib.extends (_: lib.toFunction newArgs) origArgs newArgs: lib.extends (lib.toExtension newArgs) origArgs else newArgs: origArgs // lib.toFunction newArgs origArgs; newArgs: if !(lib.isFunction newArgs) then origArgs // newArgs else if !(lib.isFunction (newArgs origArgs)) then origArgs // newArgs origArgs else finalAttrs: origArgs // newArgs finalAttrs origArgs; in if lib.isAttrs result then result Loading
pkgs/test/overriding.nix +24 −0 Original line number Diff line number Diff line Loading @@ -434,6 +434,14 @@ let p.overridePythonAttrs (previousAttrs: { overridePythonAttrsFlag = previousAttrs.overridePythonAttrsFlag or 0 + 1; }); applyOverridePythonAttrsFP = p: p.overridePythonAttrs ( finalAttrs: previousAttrs: { overridePythonAttrsFlag = previousAttrs.overridePythonAttrsFlag or 0 + 1; overridePythonAttrsFlagP1 = finalAttrs.overridePythonAttrsFlag + 1; } ); overrideAttrsFooBar = drv: drv.overrideAttrs ( Loading Loading @@ -465,6 +473,22 @@ let expr = (applyOverridePythonAttrs (applyOverridePythonAttrs package-stub)).overridePythonAttrsFlag; expected = 2; }; overridePythonAttrs-plain = { expr = (package-stub.overridePythonAttrs { overridePythonAttrsFlag = 0; }).overridePythonAttrsFlag; expected = 0; }; overridePythonAttrs-finalAttrs = { expr = { inherit (applyOverridePythonAttrsFP package-stub) overridePythonAttrsFlag overridePythonAttrsFlagP1 ; }; expected = { overridePythonAttrsFlag = 1; overridePythonAttrsFlagP1 = 2; }; }; overrideAttrs-overridePythonAttrs-test-overrideAttrs = { expr = { inherit (applyOverridePythonAttrs (overrideAttrsFooBar package-stub)) Loading