Override `python.withPackages' with new `pythonPackages'


As in the title; how can I override a python version’s withPackages to use the packageOverrides? withPackages does not use package overrides with the following overlay:

final: prev: { python311 = prev.python311.override (super: {
    self = final.python311;
    packageOverrides = composeExtensions (super.packageOverrides or (_: _: {})) (new: old: { ... });
}); }

Thank you kindly for the help!

How are you testing the withPackages? Are you using python311.withPackages or python3.withPackages?

Interesting; that brings up another question, then: if I overrode python3 with python311, like so:

final: prev: rec {
    python3 = final.python311;
    python3Packages = python3.pkgs;
    python = python3;
    pythonPackages = trace final.python311.pkgs.rich.version python3Packages;

Why isn’t this working?

Okay, so I’ve found the problem: I’m overriding python3Packages with python311.pkgs, but the python interpreter I’m using, hy, is defined as hy = with python3Packages; toPythonApplication hy;; however, in pkgs/top-level/all-packages.nix, python3Packages is defined as python3Packages = dontRecurseIntoAttrs python310Packages;. So why isn’t python3Packages being overriden by the overlay? I fixed the problem by creating another overlay manually overriding the hy interpreter: final: prev: { hy = with final.python3.pkgs; toPythonApplication hy; };