Skip to content

Define custom nixpkgs as overlay of python dependency #581

@lfdominguez

Description

@lfdominguez

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions