Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at devShellTools-shell 144 lines 4.3 kB view raw
1{ 2 stdenv, 3 fetchFromGitHub, 4 lib, 5 fetchpatch, 6 replaceVars, 7 cmake, 8 pkg-config, 9 python3, 10 freetype, 11 zlib, 12 glib, 13 giflib, 14 libpng, 15 libjpeg, 16 libtiff, 17 libxml2, 18 cairo, 19 pango, 20 readline, 21 woff2, 22 zeromq, 23 withSpiro ? false, 24 libspiro, 25 withGTK ? false, 26 gtk3, 27 withGUI ? withGTK, 28 withPython ? true, 29 withExtras ? true, 30}: 31 32assert withGTK -> withGUI; 33 34let 35 py = python3.withPackages (ps: with ps; [ setuptools ]); 36in 37stdenv.mkDerivation rec { 38 pname = "fontforge"; 39 version = "20230101"; 40 41 src = fetchFromGitHub { 42 owner = "fontforge"; 43 repo = "fontforge"; 44 rev = version; 45 sha256 = "sha256-/RYhvL+Z4n4hJ8dmm+jbA1Ful23ni2DbCRZC5A3+pP0="; 46 }; 47 48 patches = [ 49 (fetchpatch { 50 name = "CVE-2024-25081.CVE-2024-25082.patch"; 51 url = "https://github.com/fontforge/fontforge/commit/216eb14b558df344b206bf82e2bdaf03a1f2f429.patch"; 52 hash = "sha256-aRnir09FSQMT50keoB7z6AyhWAVBxjSQsTRvBzeBuHU="; 53 }) 54 55 # Replace distutils use in the build script 56 (fetchpatch { 57 name = "replace-distutils.patch"; 58 url = "https://github.com/fontforge/fontforge/commit/8c75293e924602ed09a9481b0eeb67ba6c623a81.patch"; 59 includes = [ "pyhook/CMakeLists.txt" ]; 60 hash = "sha256-3CEwC8vygmCztKRmeD45aZIqyoj8yk5CLwxX2SGP7z4="; 61 }) 62 63 # Fixes translation compatibility with gettext 0.22 64 (fetchpatch { 65 name = "update-translation-compatibility.patch"; 66 url = "https://github.com/fontforge/fontforge/commit/642d8a3db6d4bc0e70b429622fdf01ecb09c4c10.patch"; 67 hash = "sha256-uO9uEhB64hkVa6O2tJKE8BLFR96m27d8NEN9UikNcvg="; 68 }) 69 70 # Updates to new Python initialization API 71 (fetchpatch { 72 name = "modern-python-initialization-api.patch"; 73 url = "https://github.com/fontforge/fontforge/commit/2f2ba54c15c5565acbde04eb6608868cbc871e01.patch"; 74 hash = "sha256-qF4DqFpiZDbULi9+POPM73HF6pEot8BAFSVaVCNQrMU="; 75 }) 76 77 # Provide a Nix-controlled location for the initial `sys.path` entry. 78 (replaceVars ./set-python-sys-path.patch { python = "${py}/${py.sitePackages}"; }) 79 ]; 80 81 # use $SOURCE_DATE_EPOCH instead of non-deterministic timestamps 82 postPatch = '' 83 find . -type f -name '*.c' -exec sed -r -i 's#\btime\(&(.+)\)#if (getenv("SOURCE_DATE_EPOCH")) \1=atol(getenv("SOURCE_DATE_EPOCH")); else &#g' {} \; 84 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 85 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 86 sed -r -i 's#^\s*ttf_fftm_dump#if (!getenv("SOURCE_DATE_EPOCH")) ttf_fftm_dump#g' fontforge/tottf.c 87 sed -r -i 's#sprintf\(.+ author \);#if (!getenv("SOURCE_DATE_EPOCH")) &#g' fontforgeexe/fontinfo.c 88 ''; 89 90 # do not use x87's 80-bit arithmetic, rounding errors result in very different font binaries 91 env.NIX_CFLAGS_COMPILE = lib.optionalString stdenv.hostPlatform.isi686 "-msse2 -mfpmath=sse"; 92 93 nativeBuildInputs = [ 94 pkg-config 95 cmake 96 ]; 97 98 buildInputs = [ 99 readline 100 woff2 101 zeromq 102 py 103 freetype 104 zlib 105 glib 106 giflib 107 libpng 108 libjpeg 109 libtiff 110 libxml2 111 ] 112 ++ lib.optionals withPython [ py ] 113 ++ lib.optionals withSpiro [ libspiro ] 114 ++ lib.optionals withGUI [ 115 gtk3 116 cairo 117 pango 118 ]; 119 120 cmakeFlags = [ 121 "-DCMAKE_BUILD_WITH_INSTALL_RPATH=ON" 122 ] 123 ++ lib.optional (!withSpiro) "-DENABLE_LIBSPIRO=OFF" 124 ++ lib.optional (!withGUI) "-DENABLE_GUI=OFF" 125 ++ lib.optional (!withGTK) "-DENABLE_X11=ON" 126 ++ lib.optional (!withPython) "-DENABLE_PYTHON_SCRIPTING=OFF" 127 ++ lib.optional withExtras "-DENABLE_FONTFORGE_EXTRAS=ON"; 128 129 preConfigure = '' 130 # The way $version propagates to $version of .pe-scripts (https://github.com/dejavu-fonts/dejavu-fonts/blob/358190f/scripts/generate.pe#L19) 131 export SOURCE_DATE_EPOCH=$(date -d ${version} +%s) 132 ''; 133 134 meta = { 135 description = "Font editor"; 136 homepage = "https://fontforge.github.io"; 137 platforms = lib.platforms.all; 138 license = lib.licenses.bsd3; 139 maintainers = with lib.maintainers; [ 140 philiptaron 141 ulysseszhan 142 ]; 143 }; 144}