Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Define custom nixpkgs as overlay of python dependency #581

Open
lfdominguez opened this issue Feb 9, 2024 · 0 comments
Open

Define custom nixpkgs as overlay of python dependency #581

lfdominguez opened this issue Feb 9, 2024 · 0 comments

Comments

@lfdominguez
Copy link

Hi, I have a django project (not mine) that as sub-dependency need the weasyprint 59.0 dependency. I can't use the pip one because this dependency need some patches for libs that is already included on nixpkgs pythonPackage.weasyprint, the problem is if I replace the provider to use the nixpkgs one then get this error:

> Mach-nix version: master
> Python: 3.9.9
> Cause: Requirements conflict: weasyprint (<SpecifierSet('~=59.0')>,)
> The requirements which caused the error:
>   weasyprint (<SpecifierSet('~=59.0')>,)
>
> The given requirements might contain package versions which are not yet part of the dependency DB
> currently used. The DB can be updated by specifying 'pypiDataRev' when importing mach-nix.
> For examples see: https://github.com/DavHau/mach-nix/blob/master/examples.md

I understand that this is because the nixpkgs is the 60.0 version, how can i override the dependency search by mach. Tried this:

{
  description = "Django Project";

  inputs = {
    flake-utils.url = "github:numtide/flake-utils";
    mach-nix.url = "github:DavHau/mach-nix";
  };

  outputs = { self, nixpkgs, flake-utils, mach-nix }:
    flake-utils.lib.eachDefaultSystem
      (system:
        let
          python-packages-override = self: super: {
            python39 = super.python39.override {
              packageOverrides = pyself: pysuper: {
                weasyprint = pysuper.weasyprint.overrideAttrs (old: {
                  version = "59.0";

                  src = pkgs.fetchPypi {
                    version = "59.0";
                    pname = "weasyprint";
                    hash = "sha256-VrmBIoARg1ew9jse/hgZngg0PUpWozk8HUdauHjOomo=";
                  };
                });
              };
            };
          };

          pkgs = import nixpkgs {
            inherit system;

            overlays = [
              python-packages-override
            ];
          };

          python-package = mach-nix.lib."${system}".mkPython {
            requirements = builtins.readFile ./requirements-test.txt;

            providers.weasyprint = "nixpkgs";
          };
        in
        with pkgs;
        {
            devShells.default = mkShell {
              nativeBuildInputs = [ python-package ];
	        };
        }
    );
}

But same error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant