poetry: compose packageOverrides if already defined for python interpreter

The poetry package sets `packageOverrides` to force the poetry-core and poetry versions into alignment.

Unfortunately, in doing so, it replaces any _other_ overrides that may have been put in place on the interpreter at hand.

For Python 3.12, for example, the package `babel` needs to be updated to 2.13.1. Someone can reasonably use an overlay that sets `packageOverrides` for `python312` to update `babel`, and this works in almost all circumstances; however, it does _not_ work for purposes of building `poetry`, which discards any prior overrides.

This PR uses `composeManyExtensions` to combine the new `packageOverrides` needed for poetry with any prior value that may exist.
This commit is contained in:
Charles Duffy
2023-12-10 20:30:17 -06:00
parent 1b72831944
commit 85f625165c
@@ -1,8 +1,8 @@
{ python3, fetchFromGitHub }:
{ lib, python3, fetchFromGitHub }:
let
python = python3.override {
packageOverrides = self: super: rec {
newPackageOverrides =
self: super: {
poetry = self.callPackage ./unwrapped.nix { };
# The versions of Poetry and poetry-core need to match exactly,
@@ -21,7 +21,10 @@ let
};
});
} // (plugins self);
};
python = python3.override (old: {
packageOverrides = lib.composeManyExtensions
((if old ? packageOverrides then [ old.packageOverrides ] else [ ]) ++ [ newPackageOverrides ]);
});
plugins = ps: with ps; {
poetry-audit-plugin = callPackage ./plugins/poetry-audit-plugin.nix { };