2024-10-20 00:20:42 +00:00
|
|
|
|
{
|
|
|
|
|
lib,
|
|
|
|
|
stdenv,
|
|
|
|
|
fetchurl,
|
|
|
|
|
cmake,
|
|
|
|
|
fetchpatch,
|
|
|
|
|
ffmpeg,
|
|
|
|
|
fontconfig,
|
|
|
|
|
hunspell,
|
|
|
|
|
hyphen,
|
|
|
|
|
icu,
|
|
|
|
|
imagemagick,
|
|
|
|
|
libjpeg,
|
|
|
|
|
libmtp,
|
|
|
|
|
libpng,
|
|
|
|
|
libstemmer,
|
|
|
|
|
libuchardet,
|
|
|
|
|
libusb1,
|
|
|
|
|
piper-tts,
|
|
|
|
|
pkg-config,
|
|
|
|
|
podofo,
|
|
|
|
|
poppler_utils,
|
|
|
|
|
python3Packages,
|
|
|
|
|
qt6,
|
|
|
|
|
speechd-minimal,
|
|
|
|
|
sqlite,
|
|
|
|
|
xdg-utils,
|
|
|
|
|
wrapGAppsHook3,
|
|
|
|
|
popplerSupport ? true,
|
|
|
|
|
speechSupport ? true,
|
|
|
|
|
unrarSupport ? false,
|
2010-03-23 14:04:47 +00:00
|
|
|
|
}:
|
2010-01-07 22:47:30 +00:00
|
|
|
|
|
2023-04-21 20:31:34 +00:00
|
|
|
|
stdenv.mkDerivation (finalAttrs: {
|
2019-08-15 12:41:18 +00:00
|
|
|
|
pname = "calibre";
|
2024-10-19 21:59:55 +00:00
|
|
|
|
version = "7.20.0";
|
2010-01-07 22:47:30 +00:00
|
|
|
|
|
|
|
|
|
src = fetchurl {
|
2023-04-21 20:31:34 +00:00
|
|
|
|
url = "https://download.calibre-ebook.com/${finalAttrs.version}/calibre-${finalAttrs.version}.tar.xz";
|
2024-10-19 21:59:55 +00:00
|
|
|
|
hash = "sha256-BhJEJsQKk/kJxycm/1mbtlrSaeFQPvWGGB9DUMidgII=";
|
2010-01-07 22:47:30 +00:00
|
|
|
|
};
|
|
|
|
|
|
2016-01-05 20:35:08 +00:00
|
|
|
|
patches = [
|
2021-10-18 18:08:51 +00:00
|
|
|
|
# allow for plugin update check, but no calibre version check
|
|
|
|
|
(fetchpatch {
|
2021-11-10 22:14:04 +00:00
|
|
|
|
name = "0001-only-plugin-update.patch";
|
2023-09-08 15:00:59 +00:00
|
|
|
|
url = "https://raw.githubusercontent.com/debian-calibre/calibre/debian/${finalAttrs.version}+ds-1/debian/patches/0001-only-plugin-update.patch";
|
2024-04-20 10:08:57 +00:00
|
|
|
|
hash = "sha256-mHZkUoVcoVi9XBOSvM5jyvpOTCcM91g9+Pa/lY6L5p8=";
|
2022-01-02 17:50:56 +00:00
|
|
|
|
})
|
|
|
|
|
(fetchpatch {
|
2023-04-21 13:16:12 +00:00
|
|
|
|
name = "0007-Hardening-Qt-code.patch";
|
2023-09-08 15:00:59 +00:00
|
|
|
|
url = "https://raw.githubusercontent.com/debian-calibre/calibre/debian/${finalAttrs.version}+ds-1/debian/patches/hardening/0007-Hardening-Qt-code.patch";
|
2024-10-19 21:59:55 +00:00
|
|
|
|
hash = "sha256-8tOxFCmZal+JxOz6LeuUr+TgX7IaxC9Ow73bMgFJPt8=";
|
2021-10-18 18:08:51 +00:00
|
|
|
|
})
|
2024-10-20 00:20:42 +00:00
|
|
|
|
] ++ lib.optional (!unrarSupport) ./dont_build_unrar_plugin.patch;
|
2016-01-02 17:52:57 +00:00
|
|
|
|
|
|
|
|
|
prePatch = ''
|
2022-10-07 10:20:43 +00:00
|
|
|
|
sed -i "s@\[tool.sip.project\]@[tool.sip.project]\nsip-include-dirs = [\"${python3Packages.pyqt6}/${python3Packages.python.sitePackages}/PyQt6/bindings\"]@g" \
|
2021-01-13 20:39:14 +00:00
|
|
|
|
setup/build.py
|
2016-09-07 02:32:06 +00:00
|
|
|
|
|
|
|
|
|
# Remove unneeded files and libs
|
2021-02-14 20:02:54 +00:00
|
|
|
|
rm -rf src/odf resources/calibre-portable.*
|
2013-08-25 07:49:20 +00:00
|
|
|
|
'';
|
|
|
|
|
|
2016-04-25 18:37:47 +00:00
|
|
|
|
dontUseQmakeConfigure = true;
|
2022-10-07 10:20:43 +00:00
|
|
|
|
dontUseCmakeConfigure = true;
|
2016-04-25 18:37:47 +00:00
|
|
|
|
|
2022-10-07 10:20:43 +00:00
|
|
|
|
nativeBuildInputs = [
|
|
|
|
|
cmake
|
|
|
|
|
pkg-config
|
2024-10-20 00:19:24 +00:00
|
|
|
|
qt6.qmake
|
|
|
|
|
qt6.wrapQtAppsHook
|
2024-04-26 20:24:03 +00:00
|
|
|
|
wrapGAppsHook3
|
2022-10-07 10:20:43 +00:00
|
|
|
|
];
|
2019-09-28 12:47:41 +00:00
|
|
|
|
|
2016-09-07 02:32:06 +00:00
|
|
|
|
buildInputs = [
|
2024-10-19 21:59:55 +00:00
|
|
|
|
ffmpeg
|
2020-09-06 02:14:02 +00:00
|
|
|
|
fontconfig
|
|
|
|
|
hunspell
|
|
|
|
|
hyphen
|
|
|
|
|
icu
|
2020-01-13 13:28:24 +00:00
|
|
|
|
imagemagick
|
|
|
|
|
libjpeg
|
2020-09-06 02:14:02 +00:00
|
|
|
|
libmtp
|
|
|
|
|
libpng
|
2021-07-31 18:33:49 +00:00
|
|
|
|
libstemmer
|
2022-10-07 10:20:43 +00:00
|
|
|
|
libuchardet
|
2020-09-06 02:14:02 +00:00
|
|
|
|
libusb1
|
2024-10-19 21:59:55 +00:00
|
|
|
|
piper-tts
|
2020-01-13 13:28:24 +00:00
|
|
|
|
podofo
|
2020-09-06 02:14:02 +00:00
|
|
|
|
poppler_utils
|
2024-10-20 00:19:24 +00:00
|
|
|
|
qt6.qtbase
|
|
|
|
|
qt6.qtwayland
|
2020-01-13 13:28:24 +00:00
|
|
|
|
sqlite
|
2024-10-20 00:20:42 +00:00
|
|
|
|
(python3Packages.python.withPackages (
|
|
|
|
|
ps:
|
|
|
|
|
with ps;
|
|
|
|
|
[
|
2024-06-29 07:08:45 +00:00
|
|
|
|
(apsw.overrideAttrs (oldAttrs: {
|
|
|
|
|
setupPyBuildFlags = [ "--enable=load_extension" ];
|
|
|
|
|
}))
|
|
|
|
|
beautifulsoup4
|
|
|
|
|
css-parser
|
|
|
|
|
cssselect
|
|
|
|
|
python-dateutil
|
|
|
|
|
dnspython
|
|
|
|
|
faust-cchardet
|
|
|
|
|
feedparser
|
|
|
|
|
html2text
|
|
|
|
|
html5-parser
|
|
|
|
|
lxml
|
|
|
|
|
markdown
|
|
|
|
|
mechanize
|
|
|
|
|
msgpack
|
|
|
|
|
netifaces
|
|
|
|
|
pillow
|
|
|
|
|
pychm
|
|
|
|
|
pyqt-builder
|
|
|
|
|
pyqt6
|
|
|
|
|
python
|
|
|
|
|
regex
|
|
|
|
|
sip
|
|
|
|
|
setuptools
|
|
|
|
|
zeroconf
|
|
|
|
|
jeepney
|
|
|
|
|
pycryptodome
|
|
|
|
|
xxhash
|
|
|
|
|
# the following are distributed with calibre, but we use upstream instead
|
|
|
|
|
odfpy
|
2024-10-20 00:20:42 +00:00
|
|
|
|
]
|
|
|
|
|
++
|
|
|
|
|
lib.optionals (lib.lists.any (p: p == stdenv.hostPlatform.system) pyqt6-webengine.meta.platforms)
|
|
|
|
|
[
|
|
|
|
|
# much of calibre's functionality is usable without a web
|
|
|
|
|
# browser, so we enable building on platforms which qtwebengine
|
|
|
|
|
# does not support by simply omitting qtwebengine.
|
|
|
|
|
pyqt6-webengine
|
|
|
|
|
]
|
|
|
|
|
++ lib.optional (unrarSupport) unrardll
|
|
|
|
|
))
|
2021-02-01 08:05:09 +00:00
|
|
|
|
xdg-utils
|
2024-07-24 13:36:20 +00:00
|
|
|
|
] ++ lib.optional (speechSupport) speechd-minimal;
|
2010-01-07 22:47:30 +00:00
|
|
|
|
|
|
|
|
|
installPhase = ''
|
2017-06-05 05:10:49 +00:00
|
|
|
|
runHook preInstall
|
|
|
|
|
|
2010-02-28 22:42:39 +00:00
|
|
|
|
export HOME=$TMPDIR/fakehome
|
2016-04-16 17:45:46 +00:00
|
|
|
|
export POPPLER_INC_DIR=${poppler_utils.dev}/include/poppler
|
2016-01-24 07:30:11 +00:00
|
|
|
|
export POPPLER_LIB_DIR=${poppler_utils.out}/lib
|
2016-05-22 11:41:15 +00:00
|
|
|
|
export MAGICK_INC=${imagemagick.dev}/include/ImageMagick
|
|
|
|
|
export MAGICK_LIB=${imagemagick.out}/lib
|
2015-10-05 10:23:02 +00:00
|
|
|
|
export FC_INC_DIR=${fontconfig.dev}/include/fontconfig
|
|
|
|
|
export FC_LIB_DIR=${fontconfig.lib}/lib
|
2018-11-07 05:13:03 +00:00
|
|
|
|
export PODOFO_INC_DIR=${podofo.dev}/include/podofo
|
|
|
|
|
export PODOFO_LIB_DIR=${podofo.lib}/lib
|
2020-04-02 11:40:18 +00:00
|
|
|
|
export XDG_DATA_HOME=$out/share
|
|
|
|
|
export XDG_UTILS_INSTALL_MODE="user"
|
2024-10-19 21:59:55 +00:00
|
|
|
|
export PIPER_TTS_DIR=${piper-tts}/bin
|
2020-04-02 11:40:18 +00:00
|
|
|
|
|
2024-06-29 07:08:45 +00:00
|
|
|
|
python setup.py install --root=$out \
|
2020-04-02 11:40:18 +00:00
|
|
|
|
--prefix=$out \
|
|
|
|
|
--libdir=$out/lib \
|
|
|
|
|
--staging-root=$out \
|
|
|
|
|
--staging-libdir=$out/lib \
|
|
|
|
|
--staging-sharedir=$out/share
|
|
|
|
|
|
2010-01-07 22:47:30 +00:00
|
|
|
|
PYFILES="$out/bin/* $out/lib/calibre/calibre/web/feeds/*.py
|
|
|
|
|
$out/lib/calibre/calibre/ebooks/metadata/*.py
|
|
|
|
|
$out/lib/calibre/calibre/ebooks/rtf2xml/*.py"
|
|
|
|
|
|
2011-12-29 16:22:46 +00:00
|
|
|
|
sed -i "s/env python[0-9.]*/python/" $PYFILES
|
2014-08-23 10:03:03 +00:00
|
|
|
|
sed -i "2i import sys; sys.argv[0] = 'calibre'" $out/bin/calibre
|
|
|
|
|
|
2017-07-28 15:46:54 +00:00
|
|
|
|
mkdir -p $out/share
|
|
|
|
|
cp -a man-pages $out/share/man
|
|
|
|
|
|
2017-06-05 05:10:49 +00:00
|
|
|
|
runHook postInstall
|
2010-01-07 22:47:30 +00:00
|
|
|
|
'';
|
|
|
|
|
|
2019-08-11 14:42:47 +00:00
|
|
|
|
# Wrap manually
|
|
|
|
|
dontWrapQtApps = true;
|
2022-12-17 17:58:44 +00:00
|
|
|
|
dontWrapGApps = true;
|
2019-08-11 14:42:47 +00:00
|
|
|
|
|
2024-06-22 03:30:13 +00:00
|
|
|
|
preFixup =
|
|
|
|
|
let
|
|
|
|
|
popplerArgs = "--prefix PATH : ${poppler_utils.out}/bin";
|
|
|
|
|
in
|
|
|
|
|
''
|
|
|
|
|
for program in $out/bin/*; do
|
|
|
|
|
wrapProgram $program \
|
|
|
|
|
''${qtWrapperArgs[@]} \
|
|
|
|
|
''${gappsWrapperArgs[@]} \
|
|
|
|
|
${if popplerSupport then popplerArgs else ""}
|
|
|
|
|
done
|
|
|
|
|
'';
|
2019-07-25 12:56:26 +00:00
|
|
|
|
|
2024-09-01 16:34:54 +00:00
|
|
|
|
doInstallCheck = true;
|
|
|
|
|
installCheckInputs = with python3Packages; [
|
|
|
|
|
fonttools
|
|
|
|
|
psutil
|
|
|
|
|
];
|
|
|
|
|
installCheckPhase = ''
|
|
|
|
|
runHook preInstallCheck
|
|
|
|
|
|
|
|
|
|
ETN='--exclude-test-name'
|
|
|
|
|
EXCLUDED_FLAGS=(
|
|
|
|
|
$ETN 'test_7z' # we don't include 7z support
|
|
|
|
|
$ETN 'test_zstd' # we don't include zstd support
|
|
|
|
|
$ETN 'test_qt' # we don't include svg or webp support
|
|
|
|
|
$ETN 'test_import_of_all_python_modules' # explores actual file paths, gets confused
|
2024-09-14 14:09:48 +00:00
|
|
|
|
$ETN 'test_websocket_basic' # flakey
|
2024-09-01 16:34:54 +00:00
|
|
|
|
${lib.optionalString (!unrarSupport) "$ETN 'test_unrar'"}
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
python setup.py test ''${EXCLUDED_FLAGS[@]}
|
|
|
|
|
|
|
|
|
|
runHook postInstallCheck
|
|
|
|
|
'';
|
|
|
|
|
|
2023-04-21 20:30:04 +00:00
|
|
|
|
meta = {
|
2019-09-28 12:47:41 +00:00
|
|
|
|
homepage = "https://calibre-ebook.com";
|
2021-02-14 20:02:54 +00:00
|
|
|
|
description = "Comprehensive e-book software";
|
|
|
|
|
longDescription = ''
|
|
|
|
|
calibre is a powerful and easy to use e-book manager. Users say it’s
|
|
|
|
|
outstanding and a must-have. It’ll allow you to do nearly everything and
|
|
|
|
|
it takes things a step beyond normal e-book software. It’s also completely
|
|
|
|
|
free and open source and great for both casual users and computer experts.
|
|
|
|
|
'';
|
2023-04-21 20:31:34 +00:00
|
|
|
|
changelog = "https://github.com/kovidgoyal/calibre/releases/tag/v${finalAttrs.version}";
|
2024-10-20 00:20:42 +00:00
|
|
|
|
license = if unrarSupport then lib.licenses.unfreeRedistributable else lib.licenses.gpl3Plus;
|
2023-09-12 09:58:43 +00:00
|
|
|
|
maintainers = with lib.maintainers; [ pSub ];
|
2023-04-21 20:30:04 +00:00
|
|
|
|
platforms = lib.platforms.unix;
|
|
|
|
|
broken = stdenv.hostPlatform.isDarwin;
|
2010-01-07 22:47:30 +00:00
|
|
|
|
};
|
2023-04-21 20:31:34 +00:00
|
|
|
|
})
|