1 { stdenv, fetchFromGitHub, lib, fetchpatch
2 , cmake, uthash, pkg-config
3 , python, freetype, zlib, glib, giflib, libpng, libjpeg, libtiff, libxml2, cairo, pango
4 , readline, woff2, zeromq
5 , withSpiro ? false, libspiro
6 , withGTK ? false, gtk3
13 assert withGTK -> withGUI;
15 stdenv.mkDerivation rec {
19 src = fetchFromGitHub {
23 sha256 = "sha256-/RYhvL+Z4n4hJ8dmm+jbA1Ful23ni2DbCRZC5A3+pP0=";
28 name = "CVE-2024-25081.CVE-2024-25082.patch";
29 url = "https://github.com/fontforge/fontforge/commit/216eb14b558df344b206bf82e2bdaf03a1f2f429.patch";
30 hash = "sha256-aRnir09FSQMT50keoB7z6AyhWAVBxjSQsTRvBzeBuHU=";
33 # https://github.com/fontforge/fontforge/pull/5423
34 ./replace-distutils.patch
37 # use $SOURCE_DATE_EPOCH instead of non-deterministic timestamps
39 find . -type f -name '*.c' -exec sed -r -i 's#\btime\(&(.+)\)#if (getenv("SOURCE_DATE_EPOCH")) \1=atol(getenv("SOURCE_DATE_EPOCH")); else &#g' {} \;
40 sed -r -i 's#author\s*!=\s*NULL#& \&\& !getenv("SOURCE_DATE_EPOCH")#g' fontforge/cvexport.c fontforge/dumppfa.c fontforge/print.c fontforge/svg.c fontforge/splineutil2.c
41 sed -r -i 's#\bb.st_mtime#getenv("SOURCE_DATE_EPOCH") ? atol(getenv("SOURCE_DATE_EPOCH")) : &#g' fontforge/parsepfa.c fontforge/sfd.c fontforge/svg.c
42 sed -r -i 's#^\s*ttf_fftm_dump#if (!getenv("SOURCE_DATE_EPOCH")) ttf_fftm_dump#g' fontforge/tottf.c
43 sed -r -i 's#sprintf\(.+ author \);#if (!getenv("SOURCE_DATE_EPOCH")) &#g' fontforgeexe/fontinfo.c
46 # do not use x87's 80-bit arithmetic, rouding errors result in very different font binaries
47 env.NIX_CFLAGS_COMPILE = lib.optionalString stdenv.hostPlatform.isi686 "-msse2 -mfpmath=sse";
49 nativeBuildInputs = [ pkg-config cmake ];
51 readline uthash woff2 zeromq
52 python freetype zlib glib giflib libpng libjpeg libtiff libxml2
54 ++ lib.optionals withSpiro [ libspiro ]
55 ++ lib.optionals withGUI [ gtk3 cairo pango ]
56 ++ lib.optionals stdenv.hostPlatform.isDarwin [ Carbon Cocoa ];
58 cmakeFlags = [ "-DCMAKE_BUILD_WITH_INSTALL_RPATH=ON" ]
59 ++ lib.optional (!withSpiro) "-DENABLE_LIBSPIRO=OFF"
60 ++ lib.optional (!withGUI) "-DENABLE_GUI=OFF"
61 ++ lib.optional (!withGTK) "-DENABLE_X11=ON"
62 ++ lib.optional withExtras "-DENABLE_FONTFORGE_EXTRAS=ON";
65 # The way $version propagates to $version of .pe-scripts (https://github.com/dejavu-fonts/dejavu-fonts/blob/358190f/scripts/generate.pe#L19)
66 export SOURCE_DATE_EPOCH=$(date -d ${version} +%s)
70 # get rid of the runtime dependency on python
71 lib.optionalString (!withPython) ''
72 rm -r "$out/share/fontforge/python"
76 description = "Font editor";
77 homepage = "https://fontforge.github.io";
78 platforms = platforms.all;
79 license = licenses.bsd3;
80 maintainers = [ maintainers.erictapen ];