From 3b701aa4b6c0f9edd1059d25cecefdd4379212fe Mon Sep 17 00:00:00 2001 From: Jan Tojnar Date: Fri, 3 Jul 2020 05:44:35 +0200 Subject: [PATCH 1/2] gimp: Fix interpreter path MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit GIMP uses python interpreter specified in pygimp.interp file for running Python plug-ins, so any Python related wrapping is useless. It will pick up and use the python from build PATH. Let’s use a python environment containing pygtk, which is needed by many plug-ins. Closes: https://github.com/NixOS/nixpkgs/issues/87883 --- pkgs/applications/graphics/gimp/default.nix | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/pkgs/applications/graphics/gimp/default.nix b/pkgs/applications/graphics/gimp/default.nix index 9e448fa23a4..1eee37223f1 100644 --- a/pkgs/applications/graphics/gimp/default.nix +++ b/pkgs/applications/graphics/gimp/default.nix @@ -28,9 +28,10 @@ , ghostscript , aalib , shared-mime-info -, python2Packages +, python2 , libexif , gettext +, makeWrapper , xorg , glib-networking , libmypaint @@ -47,7 +48,7 @@ }: let - inherit (python2Packages) pygtk wrapPython python; + python = python2.withPackages (pp: [ pp.pygtk ]); in stdenv.mkDerivation rec { pname = "gimp"; version = "2.10.20"; @@ -63,7 +64,7 @@ in stdenv.mkDerivation rec { pkgconfig intltool gettext - wrapPython + makeWrapper ]; buildInputs = [ @@ -97,7 +98,6 @@ in stdenv.mkDerivation rec { libwebp libheif python - pygtk libexif xorg.libXpm glib-networking @@ -116,8 +116,6 @@ in stdenv.mkDerivation rec { gegl ]; - pythonPath = [ pygtk ]; - # Check if librsvg was built with --disable-pixbuf-loader. PKG_CONFIG_GDK_PIXBUF_2_0_GDK_PIXBUF_MODULEDIR = "${librsvg}/${gdk-pixbuf.moduleDir}"; @@ -136,9 +134,7 @@ in stdenv.mkDerivation rec { ]; postFixup = '' - wrapPythonProgramsIn $out/lib/gimp/${passthru.majorVersion}/plug-ins/ wrapProgram $out/bin/gimp-${lib.versions.majorMinor version} \ - --prefix PYTHONPATH : "$PYTHONPATH" \ --set GDK_PIXBUF_MODULE_FILE "$GDK_PIXBUF_MODULE_FILE" ''; From 64ec4fd65d14d89903364048a2a8090b23a7d8ac Mon Sep 17 00:00:00 2001 From: Jan Tojnar Date: Fri, 3 Jul 2020 21:03:26 +0200 Subject: [PATCH 2/2] gimp: Hardcode interpreter paths MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The E (extension) line in pygimp.interp prints the following warnings: GIMP-Warning: Bad interpreter referenced in interpreter file /nix/store/5c91dah385gn70blsn6i5rzncqj3ks0y-gimp-with-plugins-2.10.18/lib/gimp/2.0/interpreters/pygimp.interp: python2 GIMP-Warning: Bad binary format string in interpreter file /nix/store/5c91dah385gn70blsn6i5rzncqj3ks0y-gimp-with-plugins-2.10.18/lib/gimp/2.0/interpreters/pygimp.interp This means that the py extension will not be registered when python2 is not in PATH. To prevent this, let’s hardcode the absolute python2 path. https://github.com/NixOS/nixpkgs/issues/60937#issuecomment-653652093 Closes: https://github.com/NixOS/nixpkgs/issues/60937 --- pkgs/applications/graphics/gimp/default.nix | 24 ++++++++++++------- .../gimp/hardcode-plugin-interpreters.patch | 11 +++++++++ 2 files changed, 26 insertions(+), 9 deletions(-) create mode 100644 pkgs/applications/graphics/gimp/hardcode-plugin-interpreters.patch diff --git a/pkgs/applications/graphics/gimp/default.nix b/pkgs/applications/graphics/gimp/default.nix index 1eee37223f1..aa440f2c47a 100644 --- a/pkgs/applications/graphics/gimp/default.nix +++ b/pkgs/applications/graphics/gimp/default.nix @@ -2,6 +2,7 @@ , lib , fetchurl , substituteAll +, autoreconfHook , pkgconfig , intltool , babl @@ -60,7 +61,21 @@ in stdenv.mkDerivation rec { sha256 = "4S+fh0saAHxCd7YKqB4LZzML5+YVPldJ6tg5uQL8ezw="; }; + patches = [ + # to remove compiler from the runtime closure, reference was retained via + # gimp --version --verbose output + (substituteAll { + src = ./remove-cc-reference.patch; + cc_version = stdenv.cc.cc.name; + }) + + # Use absolute paths instead of relying on PATH + # to make sure plug-ins are loaded by the correct interpreter. + ./hardcode-plugin-interpreters.patch + ]; + nativeBuildInputs = [ + autoreconfHook # hardcode-plugin-interpreters.patch changes Makefile.am pkgconfig intltool gettext @@ -124,15 +139,6 @@ in stdenv.mkDerivation rec { export GIO_EXTRA_MODULES="${glib-networking}/lib/gio/modules:$GIO_EXTRA_MODULES" ''; - patches = [ - # to remove compiler from the runtime closure, reference was retained via - # gimp --version --verbose output - (substituteAll { - src = ./remove-cc-reference.patch; - cc_version = stdenv.cc.cc.name; - }) - ]; - postFixup = '' wrapProgram $out/bin/gimp-${lib.versions.majorMinor version} \ --set GDK_PIXBUF_MODULE_FILE "$GDK_PIXBUF_MODULE_FILE" diff --git a/pkgs/applications/graphics/gimp/hardcode-plugin-interpreters.patch b/pkgs/applications/graphics/gimp/hardcode-plugin-interpreters.patch new file mode 100644 index 00000000000..1528404c31d --- /dev/null +++ b/pkgs/applications/graphics/gimp/hardcode-plugin-interpreters.patch @@ -0,0 +1,11 @@ +--- a/plug-ins/pygimp/Makefile.am ++++ b/plug-ins/pygimp/Makefile.am +@@ -157,7 +157,7 @@ install-interp-file: + echo 'python=$(PYBIN_PATH)' > '$(DESTDIR)$(pyinterpfile)' + echo 'python2=$(PYBIN_PATH)' >> '$(DESTDIR)$(pyinterpfile)' + echo '/usr/bin/python=$(PYBIN_PATH)' >> '$(DESTDIR)$(pyinterpfile)' +- echo ":Python:E::py::`basename $(PYTHON)`:" >> '$(DESTDIR)$(pyinterpfile)' ++ echo ":Python:E::py::$(PYTHON):" >> '$(DESTDIR)$(pyinterpfile)' + + install-data-local: install-env-file install-interp-file +