Merge pull request #66483 from worldofpeace/calibre-cleanup

calibre: wrap manually
This commit is contained in:
worldofpeace 2019-08-12 12:44:15 -04:00 committed by GitHub
commit 8a139bfa9f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,12 +1,12 @@
{ stdenv, fetchurl, poppler_utils, pkgconfig, libpng
{ stdenv, mkDerivation, fetchurl, poppler_utils, pkgconfig, libpng
, imagemagick, libjpeg, fontconfig, podofo, qtbase, qmake, icu, sqlite
, makeWrapper, unrarSupport ? false, chmlib, python2Packages, libusb1, libmtp
, unrarSupport ? false, chmlib, python2Packages, libusb1, libmtp
, xdg_utils, makeDesktopItem, wrapGAppsHook, removeReferencesTo, qt5
}:
stdenv.mkDerivation rec {
version = "3.45.2";
mkDerivation rec {
name = "calibre-${version}";
version = "3.45.2";
src = fetchurl {
url = "https://download.calibre-ebook.com/${version}/${name}.tar.xz";
@ -35,11 +35,11 @@ stdenv.mkDerivation rec {
enableParallelBuilding = true;
nativeBuildInputs = [ makeWrapper pkgconfig qmake removeReferencesTo qt5.wrapQtAppsHook ];
nativeBuildInputs = [ pkgconfig qmake removeReferencesTo wrapGAppsHook ];
buildInputs = [
poppler_utils libpng imagemagick libjpeg
fontconfig podofo qtbase chmlib icu sqlite libusb1 libmtp xdg_utils wrapGAppsHook
fontconfig podofo qtbase chmlib icu sqlite libusb1 libmtp xdg_utils
] ++ (with python2Packages; [
apsw cssselect css-parser dateutil dnspython html5-parser lxml mechanize netifaces pillow
python pyqt5_with_qtwebkit sip
@ -48,10 +48,6 @@ stdenv.mkDerivation rec {
odfpy
]);
qtWrapperArgs = [
"--prefix PATH : ${poppler_utils.out}/bin"
];
installPhase = ''
runHook preInstall
@ -74,10 +70,6 @@ stdenv.mkDerivation rec {
sed -i "s/env python[0-9.]*/python/" $PYFILES
sed -i "2i import sys; sys.argv[0] = 'calibre'" $out/bin/calibre
for program in $out/bin/*; do
wrapQtApp $program --prefix PYTHONPATH : $PYTHONPATH
done
# Replace @out@ by the output path.
mkdir -p $out/share/applications/
cp {$calibreDesktopItem,$ebookEditDesktopItem,$ebookViewerDesktopItem}/share/applications/* $out/share/applications/
@ -91,15 +83,23 @@ stdenv.mkDerivation rec {
runHook postInstall
'';
# Wrap manually
dontWrapQtApps = true;
dontWrapGApps = true;
# Remove some references to shrink the closure size. This reference (as of
# 2018-11-06) was a single string like the following:
# /nix/store/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx-podofo-0.9.6-dev/include/podofo/base/PdfVariant.h
preFixup = ''
remove-references-to -t ${podofo.dev} $out/lib/calibre/calibre/plugins/podofo.so
'';
postFixup = ''
for program in $out/bin/*; do
wrapProgram $program \
''${qtWrapperArgs[@]} \
''${gappsWrapperArgs[@]} \
--prefix PYTHONPATH : $PYTHONPATH \
--prefix PATH : ${poppler_utils.out}/bin
done
'';
disallowedReferences = [ podofo.dev ];