diff options
author | toonn <toonn@toonn.io> | 2022-03-26 11:34:50 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-26 11:34:50 +0100 |
commit | d81e16ccf602e4600f88fee523886d1716acac48 (patch) | |
tree | 0767c0ff1a3fbb5c9212b87e5e681202919fc2a4 /pkgs/applications/misc/mupdf | |
parent | a5068a9f476d8e8396bb2db77274449e04b68ab8 (diff) |
mupdf: Refactor desktop item (#165117)
Co-authored-by: Sandro <sandro.jaeckel@gmail.com>
Diffstat (limited to 'pkgs/applications/misc/mupdf')
-rw-r--r-- | pkgs/applications/misc/mupdf/default.nix | 51 |
1 files changed, 36 insertions, 15 deletions
diff --git a/pkgs/applications/misc/mupdf/default.nix b/pkgs/applications/misc/mupdf/default.nix index 102c80f6d1263..99812bcdc8c9b 100644 --- a/pkgs/applications/misc/mupdf/default.nix +++ b/pkgs/applications/misc/mupdf/default.nix @@ -2,6 +2,8 @@ , lib , fetchurl , fetchpatch +, copyDesktopItems +, makeDesktopItem , desktopToDarwinBundle , pkg-config , freetype @@ -56,8 +58,9 @@ stdenv.mkDerivation rec { ++ lib.optionals (!enableX11) [ "HAVE_X11=no" ] ++ lib.optionals (!enableGL) [ "HAVE_GLUT=no" ]; - nativeBuildInputs = - [ pkg-config ] ++ lib.optional stdenv.isDarwin desktopToDarwinBundle; + nativeBuildInputs = [ pkg-config ] + ++ lib.optional (enableGL || enableX11) copyDesktopItems + ++ lib.optional stdenv.isDarwin desktopToDarwinBundle; buildInputs = [ freetype harfbuzz openjpeg jbig2dec libjpeg gumbo ] ++ lib.optional stdenv.isDarwin xcbuild @@ -77,6 +80,30 @@ stdenv.mkDerivation rec { rm -rf thirdparty/{curl,freetype,glfw,harfbuzz,jbig2dec,libjpeg,openjpeg,zlib} ''; + desktopItems = [ + (makeDesktopItem { + name = pname; + desktopName = pname; + comment = meta.description; + icon = "mupdf"; + exec = "${pname} %f"; + terminal = false; + mimeTypes = [ + "application/epub+zip" + "application/oxps" + "application/pdf" + "application/vnd.ms-xpsdocument" + "application/x-cbz" + "application/x-pdf" + ]; + categories = [ "Graphics" "Viewer" ]; + keywords = [ + "mupdf" "comic" "document" "ebook" "viewer" + "cbz" "epub" "fb2" "pdf" "xps" + ]; + }) + ]; + postInstall = '' mkdir -p "$out/lib/pkgconfig" cat >"$out/lib/pkgconfig/mupdf.pc" <<EOF @@ -92,20 +119,14 @@ stdenv.mkDerivation rec { EOF moveToOutput "bin" "$bin" - '' + lib.optionalString enableX11 '' + '' + lib.optionalString (enableX11 || enableGL) '' + mkdir -p $bin/share/icons/hicolor/48x48/apps + cp docs/logo/mupdf.png $bin/share/icons/hicolor/48x48/apps + '' + (if enableGL then '' + ln -s "$bin/bin/mupdf-gl" "$bin/bin/mupdf" + '' else lib.optionalString (enableX11) '' ln -s "$bin/bin/mupdf-x11" "$bin/bin/mupdf" - mkdir -p $bin/share/applications - cat > $bin/share/applications/mupdf.desktop <<EOF - [Desktop Entry] - Type=Application - Version=1.0 - Name=mupdf - Comment=PDF viewer - Exec=$bin/bin/mupdf-x11 %f - Terminal=false - MimeType=application/pdf;application/x-pdf;application/x-cbz;application/oxps;application/vnd.ms-xpsdocument;application/epub+zip - EOF - ''; + ''); enableParallelBuilding = true; |