at master 333 lines 8.3 kB view raw
1{ 2 stdenv, 3 lib, 4 fetchurl, 5 replaceVars, 6 meson, 7 ninja, 8 pkg-config, 9 babl, 10 cfitsio, 11 gegl, 12 gtk3, 13 glib, 14 gdk-pixbuf, 15 graphviz, 16 isocodes, 17 pango, 18 cairo, 19 libarchive, 20 luajit, 21 freetype, 22 fontconfig, 23 lcms, 24 libpng, 25 libiff, 26 libilbm, 27 libjpeg, 28 libjxl, 29 poppler, 30 poppler_data, 31 libtiff, 32 libmng, 33 librsvg, 34 libwmf, 35 zlib, 36 xz, 37 libzip, 38 ghostscript, 39 aalib, 40 shared-mime-info, 41 python3, 42 libexif, 43 gettext, 44 wrapGAppsHook3, 45 libxslt, 46 gobject-introspection, 47 vala, 48 gi-docgen, 49 perl, 50 appstream-glib, 51 desktop-file-utils, 52 xorg, 53 glib-networking, 54 json-glib, 55 libmypaint, 56 llvmPackages, 57 gexiv2, 58 harfbuzz, 59 mypaint-brushes1, 60 libwebp, 61 libheif, 62 gjs, 63 libgudev, 64 openexr, 65 xvfb-run, 66 dbus, 67 adwaita-icon-theme, 68 alsa-lib, 69 desktopToDarwinBundle, 70 fetchpatch, 71}: 72 73let 74 python = python3.withPackages ( 75 pp: with pp; [ 76 pygobject3 77 ] 78 ); 79in 80stdenv.mkDerivation (finalAttrs: { 81 pname = "gimp"; 82 version = "3.0.4"; 83 84 outputs = [ 85 "out" 86 "dev" 87 "devdoc" 88 ]; 89 90 src = fetchurl { 91 url = "https://download.gimp.org/gimp/v${lib.versions.majorMinor finalAttrs.version}/gimp-${finalAttrs.version}.tar.xz"; 92 hash = "sha256-jKouwnW/CTJldWVKwnavwIP4SR58ykXRnPKeaWrsqyU="; 93 }; 94 95 patches = [ 96 # to remove compiler from the runtime closure, reference was retained via 97 # gimp --version --verbose output 98 (replaceVars ./remove-cc-reference.patch { 99 cc_version = stdenv.cc.cc.name; 100 }) 101 102 # Use absolute paths instead of relying on PATH 103 # to make sure plug-ins are loaded by the correct interpreter. 104 # TODO: This now only appears to be used on Windows. 105 (replaceVars ./hardcode-plugin-interpreters.patch { 106 python_interpreter = python.interpreter; 107 PYTHON_EXE = null; 108 }) 109 110 # D-Bus configuration is not available in the build sandbox 111 # so we need to pick up the one from the package. 112 (replaceVars ./tests-dbus-conf.patch { 113 session_conf = "${dbus.out}/share/dbus-1/session.conf"; 114 }) 115 116 # Fix a crash that occurs when trying to pick a color for text outline 117 # TODO: remove after GIMP 3.2 is released, per https://gitlab.gnome.org/GNOME/gimp/-/issues/14047#note_2491655 118 (fetchpatch { 119 url = "https://gitlab.gnome.org/GNOME/gimp/-/commit/1685c86af5d6253151d0056a9677ba469ea10164.diff"; 120 hash = "sha256-Rb3ANXWki21thByEIWkBgWEml4x9Qq2HAIB9ho1bygw="; 121 }) 122 ]; 123 124 nativeBuildInputs = [ 125 meson 126 ninja 127 pkg-config 128 gettext 129 wrapGAppsHook3 130 libxslt # for xsltproc 131 gobject-introspection 132 perl 133 vala 134 135 # for docs 136 gi-docgen 137 138 # for tests 139 desktop-file-utils 140 ] 141 ++ lib.optionals stdenv.hostPlatform.isLinux [ 142 dbus 143 xvfb-run 144 ] 145 ++ lib.optionals stdenv.hostPlatform.isDarwin [ 146 desktopToDarwinBundle 147 ]; 148 149 buildInputs = [ 150 appstream-glib # for library 151 babl 152 cfitsio 153 gegl 154 gtk3 155 glib 156 gdk-pixbuf 157 pango 158 cairo 159 libarchive 160 gexiv2 161 harfbuzz 162 isocodes 163 freetype 164 fontconfig 165 lcms 166 libpng 167 libiff 168 libilbm 169 libjpeg 170 libjxl 171 poppler 172 poppler_data 173 libtiff 174 openexr 175 libmng 176 librsvg 177 libwmf 178 zlib 179 xz 180 libzip 181 ghostscript 182 aalib 183 shared-mime-info 184 json-glib 185 libwebp 186 libheif 187 python 188 libexif 189 xorg.libXpm 190 xorg.libXmu 191 glib-networking 192 libmypaint 193 mypaint-brushes1 194 195 # New file dialogue crashes with “Icon 'image-missing' not present in theme Symbolic” without an icon theme. 196 adwaita-icon-theme 197 198 # for Lua plug-ins 199 (luajit.withPackages (pp: [ 200 pp.lgi 201 ])) 202 ] 203 ++ lib.optionals stdenv.hostPlatform.isLinux [ 204 alsa-lib 205 206 # for JavaScript plug-ins 207 gjs 208 ] 209 ++ lib.optionals stdenv.hostPlatform.isDarwin [ 210 llvmPackages.openmp 211 ] 212 ++ lib.optionals stdenv.hostPlatform.isLinux [ 213 libgudev 214 ]; 215 216 propagatedBuildInputs = [ 217 # needed by gimp-3.0.pc 218 gegl 219 cairo 220 pango 221 gexiv2 222 ]; 223 224 mesonFlags = [ 225 "-Dbug-report-url=https://github.com/NixOS/nixpkgs/issues/new" 226 "-Dicc-directory=/run/current-system/sw/share/color/icc" 227 "-Dcheck-update=no" 228 (lib.mesonEnable "gudev" stdenv.hostPlatform.isLinux) 229 (lib.mesonEnable "headless-tests" stdenv.hostPlatform.isLinux) 230 (lib.mesonEnable "linux-input" stdenv.hostPlatform.isLinux) 231 # Not very important to do downstream, save a dependency. 232 "-Dappdata-test=disabled" 233 ] 234 ++ lib.optionals stdenv.hostPlatform.isDarwin [ 235 "-Dalsa=disabled" 236 "-Djavascript=disabled" 237 ]; 238 239 doCheck = true; 240 241 env = { 242 # The check runs before glib-networking is registered 243 GIO_EXTRA_MODULES = "${glib-networking}/lib/gio/modules"; 244 245 NIX_CFLAGS_COMPILE = lib.optionalString stdenv.hostPlatform.isDarwin "-DGDK_OSX_BIG_SUR=16"; 246 247 # Check if librsvg was built with --disable-pixbuf-loader. 248 PKG_CONFIG_GDK_PIXBUF_2_0_GDK_PIXBUF_MODULEDIR = "${librsvg}/${gdk-pixbuf.moduleDir}"; 249 }; 250 251 postPatch = '' 252 patchShebangs tools/gimp-mkenums 253 254 # GIMP is executed at build time so we need to fix this. 255 # TODO: Look into if we can fix the interp thing. 256 chmod +x plug-ins/python/{colorxhtml,file-openraster,foggify,gradients-save-as-css,histogram-export,palette-offset,palette-sort,palette-to-gradient,python-eval,spyro-plus}.py 257 patchShebangs \ 258 plug-ins/python/{colorxhtml,file-openraster,foggify,gradients-save-as-css,histogram-export,palette-offset,palette-sort,palette-to-gradient,python-eval,spyro-plus}.py 259 ''; 260 261 preBuild = 262 let 263 librarySuffix = 264 if stdenv.hostPlatform.extensions.library == ".so" then 265 "3.0.so.0" 266 else if stdenv.hostPlatform.extensions.library == ".dylib" then 267 "3.0.0.dylib" 268 else 269 throw "Unsupported library extension ${stdenv.hostPlatform.extensions.library}"; 270 in 271 '' 272 # Our gobject-introspection patches make the shared library paths absolute 273 # in the GIR files. When running GIMP in build or check phase, it will try 274 # to use plug-ins, which import GIMP introspection files which will try 275 # to load the GIMP libraries which will not be installed yet. 276 # So we need to replace the absolute path with a local one. 277 # We are using a symlink that will be overridden during installation. 278 mkdir -p "$out/lib" 279 ln -s "$PWD/libgimp/libgimp-${librarySuffix}" \ 280 "$PWD/libgimpbase/libgimpbase-${librarySuffix}" \ 281 "$PWD/libgimpcolor/libgimpcolor-${librarySuffix}" \ 282 "$PWD/libgimpconfig/libgimpconfig-${librarySuffix}" \ 283 "$PWD/libgimpmath/libgimpmath-${librarySuffix}" \ 284 "$PWD/libgimpmodule/libgimpmodule-${librarySuffix}" \ 285 "$out/lib/" 286 ''; 287 288 preCheck = '' 289 # Avoid Error retrieving accessibility bus address 290 export NO_AT_BRIDGE=1 291 # Fix storing recent file list in tests 292 export HOME="$TMPDIR" 293 export XDG_DATA_DIRS="${glib.getSchemaDataDirPath gtk3}:${adwaita-icon-theme}/share:$XDG_DATA_DIRS" 294 ''; 295 296 preFixup = '' 297 gappsWrapperArgs+=(--prefix PATH : "${ 298 lib.makeBinPath [ 299 # for dot for gegl:introspect (Debug » Show Image Graph, hidden by default on stable release) 300 graphviz 301 # for gimp-script-fu-interpreter-3.0 invoked by shebang of some plug-ins 302 "$out" 303 ] 304 }") 305 ''; 306 307 postFixup = '' 308 # Cannot be in postInstall, otherwise _multioutDocs hook in preFixup will move right back. 309 moveToOutput "share/doc" "$devdoc" 310 ''; 311 312 passthru = { 313 # The declarations for `gimp-with-plugins` wrapper, 314 # used for determining plug-in installation paths 315 majorVersion = "${lib.versions.major finalAttrs.version}.0"; 316 targetLibDir = "lib/gimp/${finalAttrs.passthru.majorVersion}"; 317 targetDataDir = "share/gimp/${finalAttrs.passthru.majorVersion}"; 318 targetPluginDir = "${finalAttrs.passthru.targetLibDir}/plug-ins"; 319 targetScriptDir = "${finalAttrs.passthru.targetDataDir}/scripts"; 320 321 # probably its a good idea to use the same gtk in plugins ? 322 gtk = gtk3; 323 }; 324 325 meta = with lib; { 326 description = "GNU Image Manipulation Program"; 327 homepage = "https://www.gimp.org/"; 328 maintainers = with maintainers; [ jtojnar ]; 329 license = licenses.gpl3Plus; 330 platforms = platforms.linux; 331 mainProgram = "gimp"; 332 }; 333})