1{ lib, stdenv, fetchzip, pkg-config, glib, cairo, Carbon, fontconfig
2, libtiff, giflib, libjpeg, libpng
3, libXrender, libexif, autoreconfHook }:
4
5stdenv.mkDerivation (finalAttrs: {
6 pname = "libgdiplus";
7 version = "6.1";
8
9 # Using source archive to avoid fetching Git submodules.
10 # Git repo: https://github.com/mono/libgdiplus
11 src = fetchzip {
12 url = "https://download.mono-project.com/sources/libgdiplus/libgdiplus-${finalAttrs.version}.tar.gz";
13 hash = "sha256-+lP9ETlw3s0RUliQT1uBWZ2j6o3V9EECBQSppOYFq4Q=";
14 };
15
16 patches = [
17 # Fix pkg-config lookup when cross-compiling.
18 ./configure-pkg-config.patch
19 ];
20
21 NIX_LDFLAGS = "-lgif";
22
23 outputs = [ "out" "dev" ];
24
25 hardeningDisable = [ "format" ];
26
27 nativeBuildInputs = [ autoreconfHook pkg-config ];
28
29 configureFlags = lib.optional stdenv.cc.isClang "--host=${stdenv.hostPlatform.system}";
30
31 enableParallelBuilding = true;
32
33 buildInputs =
34 [ glib cairo fontconfig libtiff giflib
35 libjpeg libpng libXrender libexif
36 ]
37 ++ lib.optional stdenv.isDarwin Carbon;
38
39 postInstall = lib.optionalString stdenv.isDarwin ''
40 ln -s $out/lib/libgdiplus.0.dylib $out/lib/libgdiplus.so
41 '';
42
43 checkPhase = ''
44 make check -w
45 '';
46
47 meta = with lib; {
48 description = "Mono library that provides a GDI+-compatible API on non-Windows operating systems";
49 homepage = "https://www.mono-project.com/docs/gui/libgdiplus/";
50 platforms = platforms.unix;
51 license = licenses.mit;
52 };
53})