@@ -1,7 +1,7 @@
11{ stdenv, fetchurl, python, pyqt5, sip_4_16, poppler_utils, pkgconfig, libpng
22, imagemagick, libjpeg, fontconfig, podofo, qtbase, qmakeHook, icu, sqlite
33, makeWrapper, unrarSupport ? false, chmlib, pythonPackages, xz, libusb1, libmtp
4−, xdg_utils
4+, xdg_utils, makeDesktopItem
55}:
66
77stdenv.mkDerivation rec {
@@ -9,7 +9,7 @@ stdenv.mkDerivation rec {
99 name = "calibre-${version}";
1010
1111 src = fetchurl {
12− url = "http://download.calibre-ebook.com/${version}/${name}.tar.xz";
12+ url = "https://download.calibre-ebook.com/${version}/${name}.tar.xz";
1313 sha256 = "0npqvfjqj1vwa7nmnsyd4d30z40brydw275ldf1jankrp6dr9dyd";
1414 };
1515
@@ -67,11 +67,88 @@ stdenv.mkDerivation rec {
6767 wrapProgram $a --prefix PYTHONPATH : $PYTHONPATH \
6868 --prefix PATH : ${poppler_utils.out}/bin
6969 done
70+
71+ # Replace @out@ by the output path.
72+ mkdir -p $out/share/applications/
73+ cp {$calibreDesktopItem,$ebookEditDesktopItem,$ebookViewerDesktopItem}/share/applications/* $out/share/applications/
74+ for entry in $out/share/applications/*.desktop; do
75+ substituteAllInPlace $entry
76+ done
7077 '';
7178
79+ calibreDesktopItem = makeDesktopItem {
80+ name = "calibre";
81+ desktopName = "calibre";
82+ exec = "@out@/bin/calibre --detach %F";
83+ genericName = "E-book library management";
84+ icon = "@out@/share/calibre/images/library.png";
85+ comment = "Manage, convert, edit, and read e-books";
86+ mimeType = stdenv.lib.concatStringsSep ";" [
87+ "application/x-mobipocket-subscription"
88+ "application/vnd.openxmlformats-officedocument.wordprocessingml.document"
89+ "text/html"
90+ "application/x-cbc"
91+ "application/ereader"
92+ "application/oebps-package+xml"
93+ "image/vnd.djvu"
94+ "application/x-sony-bbeb"
95+ "application/vnd.ms-word.document.macroenabled.12"
96+ "text/rtf"
97+ "text/x-markdown"
98+ "application/pdf"
99+ "application/x-cbz"
100+ "application/x-mobipocket-ebook"
101+ "application/x-cbr"
102+ "application/x-mobi8-ebook"
103+ "text/fb2+xml"
104+ "application/vnd.oasis.opendocument.text"
105+ "application/epub+zip"
106+ "text/plain"
107+ "application/xhtml+xml"
108+ ];
109+ categories = "Office";
110+ extraEntries = ''
111+ Actions=ebook-edit ebook-viewer
112+
113+ [Desktop Action ebook-edit]
114+ Name=Edit E-book
115+ Icon=@out@/share/calibre/images/tweak.png
116+ Exec=@out@/bin/ebook-edit --detach %F
117+
118+ [Desktop Action ebook-viewer]
119+ Name=E-book Viewer
120+ Icon=@out@/share/calibre/images/viewer.png
121+ Exec=@out@/bin/ebook-viewer --detach %F
122+ '';
123+ };
124+
125+ ebookEditDesktopItem = makeDesktopItem {
126+ name = "calibre-edit-ebook";
127+ desktopName = "Edit E-book";
128+ genericName = "E-book Editor";
129+ comment = "Edit e-books";
130+ icon = "@out@/share/calibre/images/tweak.png";
131+ exec = "@out@/bin/ebook-edit --detach %F";
132+ categories = "Office;Publishing";
133+ mimeType = "application/epub+zip";
134+ extraEntries = "NoDisplay=true";
135+ };
136+
137+ ebookViewerDesktopItem = makeDesktopItem {
138+ name = "calibre-ebook-viewer";
139+ desktopName = "E-book Viewer";
140+ genericName = "E-book Viewer";
141+ comment = "Read e-books in all the major formats";
142+ icon = "@out@/share/calibre/images/viewer.png";
143+ exec = "@out@/bin/ebook-viewer --detach %F";
144+ categories = "Office;Viewer";
145+ mimeType = "application/epub+zip";
146+ extraEntries = "NoDisplay=true";
147+ };
148+
72149 meta = with stdenv.lib; {
73150 description = "Comprehensive e-book software";
74− homepage = http://calibre-ebook.com;
151+ homepage = https://calibre-ebook.com;
75152 license = with licenses; if unrarSupport then unfreeRedistributable else gpl3;
76153 maintainers = with maintainers; [ viric domenkozar pSub AndersonTorres ];
77154 platforms = platforms.linux;