anchor.diff: -{ lib, mkDerivation, fetchurl, poppler_utils, pkgconfig, libpng
  -, imagemagick, libjpeg, fontconfig, podofo, qtbase, qmake, icu, sqlite
  -, unrarSupport ? false, chmlib, python2Packages, libusb1, libmtp
  -, xdg_utils, makeDesktopItem, removeReferencesTo
  +{ lib
  +, mkDerivation
  +, fetchurl
  +, poppler_utils
  +, pkgconfig
  +, libpng
  +, imagemagick
  +, libjpeg
  +, fontconfig
  +, podofo
  +, qtbase
  +, qmake
  +, icu
  +, sqlite
  +, hunspell
  +, hyphen
  +, unrarSupport ? false
  +, chmlib
  +, python2Packages
  +, libusb1
  +, libmtp
  +, xdg_utils
  +, makeDesktopItem
  +, removeReferencesTo
   }:
   
   let
  
positive.code: in
  mkDerivation rec {
    pname = "calibre";
    version = "3.48.0";
  
    src = fetchurl {
      url = "https://download.calibre-ebook.com/${version}/${pname}-${version}.tar.xz";
      sha256 = "034m89h7j2088p324i1kya33dfldmqyynjxk3w98xiqkz7q2hi82";
    };
  
    patches = [
  
negative.code:   CALIBRE_PY3_PORT = builtins.toString pypkgs.isPy3k;
  
    buildInputs = [
      poppler_utils
      libpng
      imagemagick
      libjpeg
      fontconfig
      podofo
      qtbase
      chmlib
      icu
      hunspell
      hyphen
      sqlite
      libusb1
      libmtp
      xdg_utils
    ] ++ (
      with pypkgs; [
        apsw
        cssselect
        css-parser
        dateutil
        dnspython
        feedparser
        html5-parser
        lxml
        markdown
        netifaces
        pillow
        python
        pyqt5_with_qtwebkit
        sip
        regex
        msgpack
        beautifulsoup4
        html2text
        # the following are distributed with calibre, but we use upstream instead
        odfpy
      ]
    ) ++ lib.optionals (!pypkgs.isPy3k) (
      with pypkgs; [
        mechanize
      ]
    );
  
    installPhase = ''
      runHook preInstall
  