Skip to content

How to inject a Python package dependency from nixpkgs? #1099

@tesujimath

Description

@tesujimath

I am trying to use the output of a dream2nix built Python package along with some native nixpkgs Python packages.

It is failing because of duplicated instances of typing-extensions, since dream2nix has fetched one from PyPI which conflicts with the native nixpkgs one.

I have attempted to inject the nixpkgs version of typing-extensions for the packages which depend on it, like this in my default.nix:

  pip = rec {
    overrides =
      {
        alembic = {
          mkDerivation.propagatedBuildInputs = [
            config.deps.python3Packages.typing-extensions
          ];
        };

        sqlalchemy = {
          mkDerivation.propagatedBuildInputs = [
            config.deps.python3Packages.typing-extensions
          ];
        };
    };
  };

I checked the dream2nix lock file and there were no other packages depending on typing-extensions.

However, this seems to introduce the nixpkgs version of typing-extensions as an additional dependency. I can't work out how to not include the one from PyPI. Certainly the lock file refresh still fetches the PyPI version of typing-extensions.

My error message on nix build is this:

it23699> nix build
warning: Git tree '/home/guestsi/vc/agr-github/redun.nix' is dirty
error: builder for '/nix/store/j2b4q23hj9k62r84f93fkxzpbmnmyq2r-python3.12-sqlalchemy-2.0.41.drv' failed with exit code 1;
       last 25 log lines:
       >           PosixPath('/nix/store/srby6wmvg7dp454pwb6qvaxdiri38sc1-zlib-1.3.1/lib'),
       >           PosixPath('/nix/store/d52qvak789g813n4nb8ghlsvi2r2yifh-python3.12-typing-extensions-4.13.2/lib'),
       >           PosixPath('/nix/store/lq3i7vyrj2hnqwbvphsfrgaifqjprmpz-python3.12-greenlet-3.2.2/lib'),
       >           PosixPath('/nix/store/jlc4i1v2xk855jr7r4rip0126gwmpl9i-python3.12-typing-extensions-4.13.2/lib'),
       >           PosixPath('/nix/store/lq3i7vyrj2hnqwbvphsfrgaifqjprmpz-python3.12-greenlet-3.2.2/lib/python3.12/site-packages/greenlet'),
       >           PosixPath('/nix/store/lq3i7vyrj2hnqwbvphsfrgaifqjprmpz-python3.12-greenlet-3.2.2/lib/python3.12/site-packages/greenlet/tests'),
       >           PosixPath('/nix/store/8w718rm43x7z73xhw9d6vh8s4snrq67h-python3-3.12.10/lib/python3.12/lib-dynload'),
       >           PosixPath('/nix/store/8w718rm43x7z73xhw9d6vh8s4snrq67h-python3-3.12.10/lib')],
       >  'paths': [PosixPath('/nix/store/d60rp129dayxsvbh0j4m7ka9d8yg850c-python3.12-sqlalchemy-2.0.41'),
       >            PosixPath('/nix/store/00j1qj6mcgj27srisrzq5h2283vjj86a-python3.12-sqlalchemy-2.0.41-dist')],
       >  'recursive': True,
       >  'runtime_dependencies': []}
       > auto-patchelf: 0 dependencies could not be satisfied
       > Running phase: pythonCatchConflictsPhase
       > Found duplicated packages in closure for dependency 'typing_extensions':
       >   typing_extensions 4.13.2 (/nix/store/d52qvak789g813n4nb8ghlsvi2r2yifh-python3.12-typing-extensions-4.13.2)
       >     dependency chain:
       >       this derivation: /nix/store/d60rp129dayxsvbh0j4m7ka9d8yg850c-python3.12-sqlalchemy-2.0.41
       >       ...depending on: /nix/store/d52qvak789g813n4nb8ghlsvi2r2yifh-python3.12-typing-extensions-4.13.2
       >   typing_extensions 4.13.2 (/nix/store/jlc4i1v2xk855jr7r4rip0126gwmpl9i-python3.12-typing-extensions-4.13.2)
       >     dependency chain:
       >       this derivation: /nix/store/d60rp129dayxsvbh0j4m7ka9d8yg850c-python3.12-sqlalchemy-2.0.41
       >       ...depending on: /nix/store/jlc4i1v2xk855jr7r4rip0126gwmpl9i-python3.12-typing-extensions-4.13.2
       >
       > Package duplicates found in closure, see above. Usually this happens if two packages depend on different version of the same dependency.
       For full logs, run 'nix log /nix/store/j2b4q23hj9k62r84f93fkxzpbmnmyq2r-python3.12-sqlalchemy-2.0.41.drv'.
error: 1 dependencies of derivation '/nix/store/484p64mf01hd7yb9yf465bawd17lvj3j-python3.12-redun-0.26.0.drv' failed to build

This seems to be such an obvious thing to want to do, and I have seen questions along these lines, but no answers.

Is this addressed in dream2nix, or does it not play nicely alongside native nixpkgs Python packages?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions