anchor.diff:      # - switches the version update from enabled to disabled by default
       ./no_updates_dialog.patch
       # the unrar patch is not from debian
  -  ] ++ stdenv.lib.optional (!unrarSupport) ./dont_build_unrar_plugin.patch;
  +  ] ++ lib.optional (!unrarSupport) ./dont_build_unrar_plugin.patch;
   
     prePatch = ''
  -    sed -i "/pyqt_sip_dir/ s:=.*:= '${python2Packages.pyqt5_with_qtwebkit}/share/sip/PyQt5':"  \
  +    sed -i "/pyqt_sip_dir/ s:=.*:= '${pypkgs.pyqt5_with_qtwebkit}/share/sip/PyQt5':"  \
         setup/build_environment.py
   
       # Remove unneeded files and libs
  
positive.code:     extraEntries = "NoDisplay=true";
    };
  
    meta = with stdenv.lib; {
      description = "Comprehensive e-book software";
      homepage = https://calibre-ebook.com;
      license = with licenses; if unrarSupport then unfreeRedistributable else gpl3;
      maintainers = with maintainers; [ domenkozar pSub AndersonTorres ];
      platforms = platforms.linux;
  
negative.code: { 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
  }:
  
  let
    pypkgs = python2Packages;
  
  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 = [
  