Trying to make a derivation for a python module that depends on another unpackaged python module p

hi! I’m trying to make a derivation for brother_ql, a python package that, inter alia, depends on another python package, packbits.

Both brother_ql and packbits are not in nixpkgs.

The build of brother_ql fails with:

ERROR: Could not find a version that satisfies the requirement packbits (from brother-ql)
ERROR: No matching distribution found for packbits

I’ve successfully made a derivation for packbits and added it to my environment with nix-env, but I don’t know how to refer to it from the derivation for brother_ql.
How do I say, if you will, something like

buildInputs = [ ../packbits/default.nix ]; #this does not work

(The above pseudocode obviously does not work, but I hope you kinda get what I’m going for.)

Here’s what I’ve got so far for brother_ql/default.nix:

{ pkgs ? import <nixpkgs> {}, pyV ? "38" }: 
let
  commit = "73de0e330fd611769c192e98c11afc2d846d822b";  # from: Mon Apr 27 2020
  fetchPypi = import (builtins.fetchTarball {
    name = "nix-pypi-fetcher";
    url = "https://github.com/DavHau/nix-pypi-fetcher/tarball/${commit}";
    # Hash obtained using `nix-prefetch-url --unpack <url>`
    sha256 = "1c06574aznhkzvricgy5xbkyfs33kpln7fb41h8ijhib60nharnp";
  });
in

pkgs."python${pyV}".pkgs.buildPythonPackage rec {
  pname = "brother_ql";
  version = "0.9.4";

  src = fetchPypi "brother_ql" "0.9.4";


  # No tests included
  doCheck = false;

  # TODO fixme
  propagatedBuildInputs = with pkgs."python${pyV}Packages"; [
    pyusb
  ];

  meta = with pkgs.lib; {
    description = "Python Brother QL-800 access module (wraps pyusb)";
    homepage = "https://github.com/pklaus/brother_ql/";
    license = licenses.gpl3;
    #maintainers = with maintainers; [ elmarsto ];
  };
}

Fixed my own problem with an overlay. (My first overlay!)

{ config, lib, pkgs, ... }: 
let
  pyV = config.lattice.dev.python.version;
  commit = "73de0e330fd611769c192e98c11afc2d846d822b";  # from: Mon Apr 27 2020
  fetchPypi = import (builtins.fetchTarball {
    name = "nix-pypi-fetcher";
    url = "https://github.com/DavHau/nix-pypi-fetcher/tarball/${commit}";
    # Hash obtained using `nix-prefetch-url --unpack <url>`
    sha256 = "1c06574aznhkzvricgy5xbkyfs33kpln7fb41h8ijhib60nharnp";
  });
in {
  nixpkgs.overlays = [(final: prev: {
    python38Packages = prev.python38Packages // { 
      packbits = final.python38.pkgs.buildPythonPackage rec {
        pname = "packbits";
        version = "0.6";
        src = fetchPypi "packbits" "0.6";
        doCheck = false;
        meta = with pkgs.lib; {
          description = "Packbits";
          homepage = "https://github.com/kmike/packbits";
        };
      };
      brother-ql = final.python38.pkgs.buildPythonPackage rec {
        pname = "brother_ql";
        version = "0.9.4";
        src = fetchPypi "brother_ql" "0.9.4";
        doCheck = false;
        meta = with pkgs.lib; {
          description = "Python Brother QL-800 access module (wraps pyusb)";
          homepage = "https://github.com/pklaus/brother_ql/";
          license = licenses.gpl3;
        };
        propagatedBuildInputs = [ 
          prev.libusb1
          prev.python38Packages.attrs
          prev.python38Packages.click
          prev.python38Packages.pyusb
          prev.python38Packages.pillow
          prev.python38Packages.future
          final.python38Packages.packbits
        ];
      };
    };
    brother-qlweb = lib.buildPythonApplication rec {
      pname = "brother-qlweb";
      version = "0.9.4";
      src = builtins.fetchGit {
        url = "https://github.com/pklaus/brother_ql";
        name = "brother-ql";
        ref = "master";
        rev = "1cfc7e7302bb3c6ac5632cc478d4c028d7c67a92";
      };
      propagatedBuildInputs = [ 
        final.python38Packages.brother-ql
        prev.python38Packages.bottle
        prev.python38Packages.jinja2
        prev.python38Packages.pillow
      ];
    };
  })];
  home.packages = with pkgs; [ python38Packages.brother-ql ];
}


1 Like