calibre: wrap manually

Also move wrapGAppsHook to nativeBuildInputs
This commit is contained in:
worldofpeace 2019-08-11 10:42:47 -04:00
parent acbee3c116
commit 38b96afce8
1 changed files with 17 additions and 17 deletions

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