From 9eb200121764dfa8a57acd906dfccf60d760e2fc Mon Sep 17 00:00:00 2001 From: toonn Date: Wed, 9 Mar 2022 13:15:08 +0100 Subject: [PATCH 1/3] mupdf: Patch out which This popped up while fixing up the expression for Darwin. Apparently `which` isn't on the PATH there for Nix builds. May be considered an impurity on Linux. `command -v` is the POSIX way to do basically the same thing so I just patched out `which`. --- pkgs/applications/misc/mupdf/default.nix | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pkgs/applications/misc/mupdf/default.nix b/pkgs/applications/misc/mupdf/default.nix index 7bb9a89b8b39..cbe50cfdb3ce 100644 --- a/pkgs/applications/misc/mupdf/default.nix +++ b/pkgs/applications/misc/mupdf/default.nix @@ -39,6 +39,8 @@ stdenv.mkDerivation rec { sha256 = "1vfyhlqq1a0k0drcggly4bgsjasmf6lmpfbdi5xcrwdbzkagrbr1"; }; + patches = ./0001-Use-command-v-in-favor-of-which.patch; + postPatch = '' sed -i "s/__OPENJPEG__VERSION__/${openJpegVersion}/" source/fitz/load-jpx.c ''; From a149e9b220990da7fd97689742597324dcedba71 Mon Sep 17 00:00:00 2001 From: toonn Date: Wed, 9 Mar 2022 13:24:16 +0100 Subject: [PATCH 2/3] mupdf: Unbreak build on Darwin Recent changes (ea5dd0974d1e74d7338a8763b0f313bb09fa5ed9) dropped a patch Darwin needed. I've added a new unconditional patch, because it doesn't affect Linux and this way it's more obvious when the patch needs updating. I decided to add the `xcbuild` dependency because the upstream build uses `xcrun` and I don't know of a good reason not to. --- pkgs/applications/misc/mupdf/default.nix | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pkgs/applications/misc/mupdf/default.nix b/pkgs/applications/misc/mupdf/default.nix index cbe50cfdb3ce..ae8eed05b9fe 100644 --- a/pkgs/applications/misc/mupdf/default.nix +++ b/pkgs/applications/misc/mupdf/default.nix @@ -21,6 +21,7 @@ , enableGL ? true , freeglut , libGLU +, xcbuild }: let @@ -39,7 +40,9 @@ stdenv.mkDerivation rec { sha256 = "1vfyhlqq1a0k0drcggly4bgsjasmf6lmpfbdi5xcrwdbzkagrbr1"; }; - patches = ./0001-Use-command-v-in-favor-of-which.patch; + 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 @@ -54,6 +57,7 @@ stdenv.mkDerivation rec { nativeBuildInputs = [ pkg-config ]; 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 ( From 66f1f073c203a39db09fa4c5aaa37c78bd61348b Mon Sep 17 00:00:00 2001 From: toonn Date: Mon, 21 Mar 2022 16:35:56 +0100 Subject: [PATCH 3/3] mupdf: Add patches --- ...0001-Use-command-v-in-favor-of-which.patch | 25 ++++++++ .../misc/mupdf/0002-Add-Darwin-deps.patch | 57 +++++++++++++++++++ 2 files changed, 82 insertions(+) create mode 100644 pkgs/applications/misc/mupdf/0001-Use-command-v-in-favor-of-which.patch create mode 100644 pkgs/applications/misc/mupdf/0002-Add-Darwin-deps.patch diff --git a/pkgs/applications/misc/mupdf/0001-Use-command-v-in-favor-of-which.patch b/pkgs/applications/misc/mupdf/0001-Use-command-v-in-favor-of-which.patch new file mode 100644 index 000000000000..26ed3aec9fb7 --- /dev/null +++ b/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 +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/pkgs/applications/misc/mupdf/0002-Add-Darwin-deps.patch b/pkgs/applications/misc/mupdf/0002-Add-Darwin-deps.patch new file mode 100644 index 000000000000..2fe1a4afd9fd --- /dev/null +++ b/pkgs/applications/misc/mupdf/0002-Add-Darwin-deps.patch @@ -0,0 +1,57 @@ +From 0f0ccfc01cfe72d96eafee57ec6c5107f09c7238 Mon Sep 17 00:00:00 2001 +From: toonn +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) +