Unverified Commit 85f62516 authored by Charles Duffy's avatar Charles Duffy
Browse files

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.
parent 1b728319
Loading
Loading
Loading
Loading
+7 −4
Original line number Diff line number Diff line
{ 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 { };