Merge pull request #268619 from tweag/lib-descriptions
[NixPkgs.git] / pkgs / applications / graphics / gimp / default.nix
blobf3587cf2ea5d4c0bb686d4fe66e2364e849770f6
1 { stdenv
2 , lib
3 , fetchurl
4 , substituteAll
5 , autoreconfHook
6 , pkg-config
7 , intltool
8 , babl
9 , gegl
10 , gtk2
11 , glib
12 , gdk-pixbuf
13 , isocodes
14 , pango
15 , cairo
16 , freetype
17 , fontconfig
18 , lcms
19 , libpng
20 , libjpeg
21 , libjxl
22 , poppler
23 , poppler_data
24 , libtiff
25 , libmng
26 , librsvg
27 , libwmf
28 , zlib
29 , libzip
30 , ghostscript
31 , aalib
32 , shared-mime-info
33 , libexif
34 , gettext
35 , makeWrapper
36 , gtk-doc
37 , xorg
38 , glib-networking
39 , libmypaint
40 , gexiv2
41 , harfbuzz
42 , mypaint-brushes1
43 , libwebp
44 , libheif
45 , libgudev
46 , openexr
47 , desktopToDarwinBundle
48 , AppKit
49 , Cocoa
50 , gtk-mac-integration-gtk2
51 , withPython ? false
52 , python2
55 let
56   python = python2.withPackages (pp: [ pp.pygtk ]);
57 in stdenv.mkDerivation (finalAttrs: {
58   pname = "gimp";
59   version = "2.10.36";
61   outputs = [ "out" "dev" ];
63   src = fetchurl {
64     url = "http://download.gimp.org/pub/gimp/v${lib.versions.majorMinor finalAttrs.version}/gimp-${finalAttrs.version}.tar.bz2";
65     sha256 = "sha256-PTvDxppL2zrqm6LVOF7ZjqA5U/OFeq/R1pdgEe1827I=";
66   };
68   patches = [
69     # to remove compiler from the runtime closure, reference was retained via
70     # gimp --version --verbose output
71     (substituteAll {
72       src = ./remove-cc-reference.patch;
73       cc_version = stdenv.cc.cc.name;
74     })
76     # Use absolute paths instead of relying on PATH
77     # to make sure plug-ins are loaded by the correct interpreter.
78     ./hardcode-plugin-interpreters.patch
79   ];
81   nativeBuildInputs = [
82     autoreconfHook # hardcode-plugin-interpreters.patch changes Makefile.am
83     pkg-config
84     intltool
85     gettext
86     makeWrapper
87     gtk-doc
88   ] ++ lib.optionals stdenv.isDarwin [
89     desktopToDarwinBundle
90   ];
92   buildInputs = [
93     babl
94     gegl
95     gtk2
96     glib
97     gdk-pixbuf
98     pango
99     cairo
100     gexiv2
101     harfbuzz
102     isocodes
103     freetype
104     fontconfig
105     lcms
106     libpng
107     libjpeg
108     libjxl
109     poppler
110     poppler_data
111     libtiff
112     openexr
113     libmng
114     librsvg
115     libwmf
116     zlib
117     libzip
118     ghostscript
119     aalib
120     shared-mime-info
121     libwebp
122     libheif
123     libexif
124     xorg.libXpm
125     glib-networking
126     libmypaint
127     mypaint-brushes1
128   ] ++ lib.optionals stdenv.isDarwin [
129     AppKit
130     Cocoa
131     gtk-mac-integration-gtk2
132   ] ++ lib.optionals stdenv.isLinux [
133     libgudev
134   ] ++ lib.optionals withPython [
135     python
136     # Duplicated here because python.withPackages does not expose the dev output with pkg-config files
137     python2.pkgs.pygtk
138   ];
140   # needed by gimp-2.0.pc
141   propagatedBuildInputs = [
142     gegl
143   ];
145   configureFlags = [
146     "--without-webkit" # old version is required
147     "--disable-check-update"
148     "--with-bug-report-url=https://github.com/NixOS/nixpkgs/issues/new"
149     "--with-icc-directory=/run/current-system/sw/share/color/icc"
150     # fix libdir in pc files (${exec_prefix} needs to be passed verbatim)
151     "--libdir=\${exec_prefix}/lib"
152   ] ++ lib.optionals (!withPython) [
153     "--disable-python" # depends on Python2 which was EOLed on 2020-01-01
154   ];
156   enableParallelBuilding = true;
158   doCheck = true;
160   env = {
161     NIX_CFLAGS_COMPILE = lib.optionalString stdenv.isDarwin "-DGDK_OSX_BIG_SUR=16";
163     # Check if librsvg was built with --disable-pixbuf-loader.
164     PKG_CONFIG_GDK_PIXBUF_2_0_GDK_PIXBUF_MODULEDIR = "${librsvg}/${gdk-pixbuf.moduleDir}";
165   };
167   preConfigure = ''
168     # The check runs before glib-networking is registered
169     export GIO_EXTRA_MODULES="${glib-networking}/lib/gio/modules:$GIO_EXTRA_MODULES"
170   '';
172   postFixup = ''
173     wrapProgram $out/bin/gimp-${lib.versions.majorMinor finalAttrs.version} \
174       --set GDK_PIXBUF_MODULE_FILE "$GDK_PIXBUF_MODULE_FILE"
175   '';
177   passthru = {
178     # The declarations for `gimp-with-plugins` wrapper,
179     # used for determining plug-in installation paths
180     majorVersion = "${lib.versions.major finalAttrs.version}.0";
181     targetLibDir = "lib/gimp/${finalAttrs.passthru.majorVersion}";
182     targetDataDir = "share/gimp/${finalAttrs.passthru.majorVersion}";
183     targetPluginDir = "${finalAttrs.passthru.targetLibDir}/plug-ins";
184     targetScriptDir = "${finalAttrs.passthru.targetDataDir}/scripts";
186     # probably its a good idea to use the same gtk in plugins ?
187     gtk = gtk2;
189     python2Support = withPython;
190   };
192   meta = with lib; {
193     description = "The GNU Image Manipulation Program";
194     homepage = "https://www.gimp.org/";
195     maintainers = with maintainers; [ jtojnar ];
196     license = licenses.gpl3Plus;
197     platforms = platforms.unix;
198     mainProgram = "gimp";
199   };