Unverified Commit 553a6c3d authored by Matt Sturgeon's avatar Matt Sturgeon
Browse files

buildPython*: preserve overrideStdenvCompat on subsequent overrides

This is needed to support the deprecated method of overriding `stdenv`
via `overridePythonAttrs`.
parent 32ecc225
Loading
Loading
Loading
Loading
+17 −14
Original line number Diff line number Diff line
@@ -45,20 +45,23 @@ let

  overrideStdenvCompat =
    f:
    lib.fix (
      f':
      lib.mirrorFunctionArgs f (
        args:
        if !(lib.isFunction args) && (args ? stdenv) then
          lib.warnIf (lib.oldestSupportedReleaseIsAtLeast 2511) ''
            Passing `stdenv` directly to `buildPythonPackage` or `buildPythonApplication` is deprecated. You should use their `.override` function instead, e.g:
              buildPythonPackage.override { stdenv = customStdenv; } { }
        '' (f.override { inherit (args) stdenv; } (removeAttrs args [ "stdenv" ]))
          '' (f'.override { inherit (args) stdenv; } (removeAttrs args [ "stdenv" ]))
        else
          f args
      )
      // {
      # Intentionally drop the effect of overrideStdenvCompat when calling `buildPython*.override`.
      inherit (f) override;
    };
        # Preserve the effect of overrideStdenvCompat when calling `buildPython*.override`.
        override = lib.mirrorFunctionArgs f.override (newArgs: overrideStdenvCompat (f.override newArgs));
      }
    );

  mkPythonDerivation =
    if python.isPy3k then ./mk-python-derivation.nix else ./python2/mk-python-derivation.nix;
+7 −0
Original line number Diff line number Diff line
@@ -453,6 +453,13 @@ let
          })).stdenv;
        expected = pkgs.clangStdenv;
      };
      overridePythonAttrs-override-clangStdenv-deprecated-nested = {
        expr =
          (package-stub-gcc.overridePythonAttrs {
            stdenv = pkgs.clangStdenv;
          }).stdenv;
        expected = pkgs.clangStdenv;
      };

      overridePythonAttrs = {
        expr = (applyOverridePythonAttrs package-stub).overridePythonAttrsFlag;