@@ -0,0 +1,95 @@
1+{ stdenv, fetchurl, fetchpatch, autoreconfHook, pkgconfig, intltool, babl, gegl, gtk2, glib, gdk_pixbuf, isocodes
2+, pango, cairo, freetype, fontconfig, lcms, libpng, libjpeg, poppler, poppler_data, libtiff
3+, libmng, librsvg, libwmf, zlib, libzip, ghostscript, aalib, shared-mime-info
4+, python2Packages, libexif, gettext, xorg, glib-networking, libmypaint, gexiv2
5+, harfbuzz, mypaint-brushes, libwebp, libgudev, openexr
6+, AppKit, Cocoa, gtk-mac-integration }:
7+
8+let
9+ inherit (python2Packages) pygtk wrapPython python;
10+in stdenv.mkDerivation rec {
11+ name = "gimp-${version}";
12+ version = "2.10.0";
13+
14+ src = fetchurl {
15+ url = "http://download.gimp.org/pub/gimp/v${stdenv.lib.versions.majorMinor version}/${name}.tar.bz2";
16+ sha256 = "1qkxaigbfkx26xym5nzrgfrmn97cbnhn63v1saaha2nbi3xrdk3z";
17+ };
18+
19+ patches = [
20+ # fix rpath of python library https://bugzilla.gnome.org/show_bug.cgi?id=795620
21+ (fetchurl {
22+ url = https://bugzilla.gnome.org/attachment.cgi?id=371482;
23+ sha256 = "18bysndh61pvlv255xapdrfpsl5ivm51wp1w7xgk9vky9z2y3llc";
24+ })
25+
26+ # fix absolute paths stored in configuration
27+ (fetchpatch {
28+ url = https://git.gnome.org/browse/gimp/patch/?id=0fce8fdb3c056acead8322c976a96fb6fba793b6;
29+ sha256 = "09845i3bdpdbf13razr04ksvwydxcvzhjwlb4dfgdv5q203g2ris";
30+ })
31+ (fetchpatch {
32+ url = https://git.gnome.org/browse/gimp/patch/?id=f6b586237cb8c912c1503f8e6086edd17f07d4df;
33+ sha256 = "0s68885ip2wgjvsl5vqi2f1xhxdjpzqprifzgdl1vnv6gqmfy3bh";
34+ })
35+
36+ # fix pc file (needed e.g. for building plug-ins)
37+ (fetchpatch {
38+ url = https://git.gnome.org/browse/gimp/patch/?id=7e19906827d301eb70275dba089849a632a0eabe;
39+ sha256 = "0cbjfbwvzg2hqihg3rpsga405v7z2qahj22dfqn2jrb2gbhrjcp1";
40+ })
41+ ];
42+
43+ nativeBuildInputs = [ autoreconfHook pkgconfig intltool gettext wrapPython ];
44+ propagatedBuildInputs = [ gegl ]; # needed by gimp-2.0.pc
45+ buildInputs = [
46+ babl gegl gtk2 glib gdk_pixbuf pango cairo gexiv2 harfbuzz isocodes libgudev
47+ freetype fontconfig lcms libpng libjpeg poppler poppler_data libtiff openexr
48+ libmng librsvg libwmf zlib libzip ghostscript aalib shared-mime-info libwebp
49+ python pygtk libexif xorg.libXpm glib-networking libmypaint mypaint-brushes
50+ ] ++ stdenv.lib.optionals stdenv.isDarwin [ AppKit Cocoa gtk-mac-integration ];
51+
52+ pythonPath = [ pygtk ];
53+
54+ # Check if librsvg was built with --disable-pixbuf-loader.
55+ PKG_CONFIG_GDK_PIXBUF_2_0_GDK_PIXBUF_MODULEDIR = "${librsvg}/${gdk_pixbuf.moduleDir}";
56+
57+ preConfigure = ''
58+ # The check runs before glib-networking is registered
59+ export GIO_EXTRA_MODULES="${glib-networking}/lib/gio/modules:$GIO_EXTRA_MODULES"
60+ '';
61+
62+ postFixup = ''
63+ wrapPythonProgramsIn $out/lib/gimp/${passthru.majorVersion}/plug-ins/
64+ wrapProgram $out/bin/gimp-${stdenv.lib.versions.majorMinor version} \
65+ --prefix PYTHONPATH : "$PYTHONPATH" \
66+ --set GDK_PIXBUF_MODULE_FILE "$GDK_PIXBUF_MODULE_FILE"
67+ '';
68+
69+ passthru = rec {
70+ # The declarations for `gimp-with-plugins` wrapper,
71+ # used for determining plug-in installation paths
72+ majorVersion = "${stdenv.lib.versions.major version}.0";
73+ targetPluginDir = "lib/gimp/${majorVersion}/plug-ins";
74+ targetScriptDir = "lib/gimp/${majorVersion}/scripts";
75+
76+ # probably its a good idea to use the same gtk in plugins ?
77+ gtk = gtk2;
78+ };
79+
80+ configureFlags = [
81+ "--without-webkit" # old version is required
82+ ];
83+
84+ doCheck = true;
85+
86+ enableParallelBuilding = true;
87+
88+ meta = with stdenv.lib; {
89+ description = "The GNU Image Manipulation Program";
90+ homepage = https://www.gimp.org/;
91+ maintainers = with maintainers; [ jtojnar ];
92+ license = licenses.gpl3Plus;
93+ platforms = platforms.unix;
94+ };
95+}