diff --git a/pkgs/development/interpreters/python/cpython/default.nix b/pkgs/development/interpreters/python/cpython/default.nix index 97db4a9fffa8..23c85942ad70 100644 --- a/pkgs/development/interpreters/python/cpython/default.nix +++ b/pkgs/development/interpreters/python/cpython/default.nix @@ -49,7 +49,7 @@ , enableLTO ? stdenv.is64bit && stdenv.isLinux , reproducibleBuild ? false , pythonAttr ? "python${sourceVersion.major}${sourceVersion.minor}" -}: +} @ inputs: # Note: this package is used for bootstrapping fetchurl, and thus # cannot use fetchpatch! All mutable patches (generated by GitHub or @@ -83,7 +83,10 @@ let tzdataSupport = tzdata != null && passthru.pythonAtLeast "3.9"; - passthru = passthruFun rec { + passthru = let + # When we override the interpreter we also need to override the spliced versions of the interpreter + override = attr: let python = attr.override (inputs // { self = python; }); in python; + in passthruFun rec { inherit self sourceVersion packageOverrides; implementation = "cpython"; libPrefix = "python${pythonVersion}"; @@ -91,11 +94,11 @@ let pythonVersion = with sourceVersion; "${major}.${minor}"; sitePackages = "lib/${libPrefix}/site-packages"; inherit hasDistutilsCxxPatch; - pythonOnBuildForBuild = pkgsBuildBuild.${pythonAttr}; - pythonOnBuildForHost = pkgsBuildHost.${pythonAttr}; - pythonOnBuildForTarget = pkgsBuildTarget.${pythonAttr}; - pythonOnHostForHost = pkgsHostHost.${pythonAttr}; - pythonOnTargetForTarget = pkgsTargetTarget.${pythonAttr} or {}; + pythonOnBuildForBuild = override pkgsBuildBuild.${pythonAttr}; + pythonOnBuildForHost = override pkgsBuildHost.${pythonAttr}; + pythonOnBuildForTarget = override pkgsBuildTarget.${pythonAttr}; + pythonOnHostForHost = override pkgsHostHost.${pythonAttr}; + pythonOnTargetForTarget = if lib.hasAttr pythonAttr pkgsTargetTarget then (override pkgsTargetTarget.${pythonAttr}) else {}; }; version = with sourceVersion; "${major}.${minor}.${patch}${suffix}";