diff options
Diffstat (limited to 'nixpkgs/pkgs/applications/misc/mupdf')
4 files changed, 127 insertions, 17 deletions
diff --git a/nixpkgs/pkgs/applications/misc/mupdf/0001-Use-command-v-in-favor-of-which.patch b/nixpkgs/pkgs/applications/misc/mupdf/0001-Use-command-v-in-favor-of-which.patch new file mode 100644 index 000000000000..26ed3aec9fb7 --- /dev/null +++ b/nixpkgs/pkgs/applications/misc/mupdf/0001-Use-command-v-in-favor-of-which.patch @@ -0,0 +1,25 @@ +From b2935ed7e2962d73f3b493c38c0bb1e8659c0a60 Mon Sep 17 00:00:00 2001 +From: toonn <toonn@toonn.io> +Date: Tue, 8 Mar 2022 23:59:19 +0100 +Subject: [PATCH 1/2] Use command -v in favor of which + +--- + Makerules | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/Makerules b/Makerules +index 0fdaecb..6d52cca 100644 +--- a/Makerules ++++ b/Makerules +@@ -145,7 +145,7 @@ else ifeq ($(OS),MACOS) + LD = xcrun ld + RANLIB = xcrun ranlib + +- ifeq (, $(shell which pkg-config)) ++ ifeq (, $(shell command -v pkg-config)) + $(warning "No pkg-config found, install it for proper integration of libcrypto") + else + HAVE_LIBCRYPTO := $(shell pkg-config --exists 'libcrypto >= 1.1.0' && echo yes) +-- +2.17.2 (Apple Git-113) + diff --git a/nixpkgs/pkgs/applications/misc/mupdf/0002-Add-Darwin-deps.patch b/nixpkgs/pkgs/applications/misc/mupdf/0002-Add-Darwin-deps.patch new file mode 100644 index 000000000000..2fe1a4afd9fd --- /dev/null +++ b/nixpkgs/pkgs/applications/misc/mupdf/0002-Add-Darwin-deps.patch @@ -0,0 +1,57 @@ +From 0f0ccfc01cfe72d96eafee57ec6c5107f09c7238 Mon Sep 17 00:00:00 2001 +From: toonn <toonn@toonn.io> +Date: Wed, 9 Mar 2022 00:08:28 +0100 +Subject: [PATCH 2/2] Add Darwin deps + +--- + Makerules | 34 ++++++++++++++++++++++++++++++++++ + 1 file changed, 34 insertions(+) + +diff --git a/Makerules b/Makerules +index 6d52cca..a6bd0ed 100644 +--- a/Makerules ++++ b/Makerules +@@ -153,6 +153,40 @@ else ifeq ($(OS),MACOS) + LIBCRYPTO_CFLAGS := $(shell pkg-config --cflags libcrypto) -DHAVE_LIBCRYPTO + LIBCRYPTO_LIBS := $(shell pkg-config --libs libcrypto) + endif ++ # Required for mupdf-gl ++ ifeq ($(shell pkg-config --exists harfbuzz && echo yes),yes) ++ SYS_HARFBUZZ_CFLAGS := $(shell pkg-config --cflags harfbuzz) ++ SYS_HARFBUZZ_LIBS := $(shell pkg-config --libs harfbuzz) ++ endif ++ ifeq ($(shell pkg-config --exists libopenjp2 && echo yes),yes) ++ SYS_OPENJPEG_CFLAGS := $(shell pkg-config --cflags libopenjp2) ++ SYS_OPENJPEG_LIBS := $(shell pkg-config --libs libopenjp2) ++ endif ++ ifeq ($(shell pkg-config --exists freetype2 && echo yes),yes) ++ SYS_FREETYPE_CFLAGS := $(shell pkg-config --cflags freetype2) ++ SYS_FREETYPE_LIBS := $(shell pkg-config --libs freetype2) ++ endif ++ ifeq ($(shell pkg-config --exists gumbo && echo yes),yes) ++ SYS_GUMBO_CFLAGS := $(shell pkg-config --cflags gumbo) ++ SYS_GUMBO_LIBS := $(shell pkg-config --libs gumbo) ++ endif ++ # Required for mupdf-x11 ++ HAVE_X11 := $(shell pkg-config --exists x11 xext && echo yes) ++ ifeq ($(HAVE_X11),yes) ++ X11_CFLAGS := $(shell pkg-config --cflags x11 xext) ++ X11_LIBS := $(shell pkg-config --libs x11 xext) ++ endif ++ # Required for mupdf-x11-curl ++ HAVE_SYS_CURL := $(shell pkg-config --exists libcurl && echo yes) ++ ifeq ($(HAVE_SYS_CURL),yes) ++ SYS_CURL_CFLAGS := $(shell pkg-config --cflags libcurl) ++ SYS_CURL_LIBS := $(shell pkg-config --libs libcurl) ++ endif ++ HAVE_PTHREAD := yes ++ ifeq ($(HAVE_PTHREAD),yes) ++ PTHREAD_CFLAGS := ++ PTHREAD_LIBS := -lpthread ++ endif + endif + + else ifeq ($(OS),Linux) +-- +2.17.2 (Apple Git-113) + diff --git a/nixpkgs/pkgs/applications/misc/mupdf/1.17.nix b/nixpkgs/pkgs/applications/misc/mupdf/1.17.nix index 95e9c7c3307a..ec978b9fc3a2 100644 --- a/nixpkgs/pkgs/applications/misc/mupdf/1.17.nix +++ b/nixpkgs/pkgs/applications/misc/mupdf/1.17.nix @@ -82,7 +82,6 @@ in stdenv.mkDerivation rec { meta = with lib; { homepage = "https://mupdf.com"; - repositories.git = "git://git.ghostscript.com/mupdf.git"; description = "Lightweight PDF, XPS, and E-book viewer and toolkit written in portable C"; license = licenses.agpl3Plus; maintainers = with maintainers; [ vrthra fpletz ]; diff --git a/nixpkgs/pkgs/applications/misc/mupdf/default.nix b/nixpkgs/pkgs/applications/misc/mupdf/default.nix index 7bb9a89b8b39..99812bcdc8c9 100644 --- a/nixpkgs/pkgs/applications/misc/mupdf/default.nix +++ b/nixpkgs/pkgs/applications/misc/mupdf/default.nix @@ -2,6 +2,9 @@ , lib , fetchurl , fetchpatch +, copyDesktopItems +, makeDesktopItem +, desktopToDarwinBundle , pkg-config , freetype , harfbuzz @@ -10,7 +13,7 @@ , libjpeg , darwin , gumbo -, enableX11 ? true +, enableX11 ? (!stdenv.isDarwin) , libX11 , libXext , libXi @@ -21,6 +24,7 @@ , enableGL ? true , freeglut , libGLU +, xcbuild }: let @@ -39,6 +43,10 @@ stdenv.mkDerivation rec { sha256 = "1vfyhlqq1a0k0drcggly4bgsjasmf6lmpfbdi5xcrwdbzkagrbr1"; }; + patches = [ ./0001-Use-command-v-in-favor-of-which.patch + ./0002-Add-Darwin-deps.patch + ]; + postPatch = '' sed -i "s/__OPENJPEG__VERSION__/${openJpegVersion}/" source/fitz/load-jpx.c ''; @@ -50,8 +58,12 @@ stdenv.mkDerivation rec { ++ lib.optionals (!enableX11) [ "HAVE_X11=no" ] ++ lib.optionals (!enableGL) [ "HAVE_GLUT=no" ]; - nativeBuildInputs = [ pkg-config ]; + 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 ++ lib.optionals enableX11 [ libX11 libXext libXi libXrandr ] ++ lib.optionals enableCurl [ curl openssl ] ++ lib.optionals enableGL ( @@ -68,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 @@ -83,26 +119,19 @@ 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; meta = with lib; { homepage = "https://mupdf.com"; - repositories.git = "git://git.ghostscript.com/mupdf.git"; description = "Lightweight PDF, XPS, and E-book viewer and toolkit written in portable C"; license = licenses.agpl3Plus; maintainers = with maintainers; [ vrthra fpletz ]; |