From d4c94e35f8162141b48d545080e055fc9eae26a1 Mon Sep 17 00:00:00 2001 From: Ulysses Zhan Date: Wed, 13 Nov 2024 15:56:17 -0800 Subject: [PATCH 1/2] fontforge: format with nixfmt --- pkgs/tools/misc/fontforge/default.nix | 80 +++++++++++++++++++++------ 1 file changed, 62 insertions(+), 18 deletions(-) diff --git a/pkgs/tools/misc/fontforge/default.nix b/pkgs/tools/misc/fontforge/default.nix index 495a3dad8330..045cabc09d0a 100644 --- a/pkgs/tools/misc/fontforge/default.nix +++ b/pkgs/tools/misc/fontforge/default.nix @@ -1,13 +1,34 @@ -{ stdenv, fetchFromGitHub, lib, fetchpatch -, cmake, uthash, pkg-config -, python, freetype, zlib, glib, giflib, libpng, libjpeg, libtiff, libxml2, cairo, pango -, readline, woff2, zeromq -, withSpiro ? false, libspiro -, withGTK ? false, gtk3 -, withGUI ? withGTK -, withPython ? true -, withExtras ? true -, Carbon, Cocoa +{ + stdenv, + fetchFromGitHub, + lib, + fetchpatch, + cmake, + uthash, + pkg-config, + python, + freetype, + zlib, + glib, + giflib, + libpng, + libjpeg, + libtiff, + libxml2, + cairo, + pango, + readline, + woff2, + zeromq, + withSpiro ? false, + libspiro, + withGTK ? false, + gtk3, + withGUI ? withGTK, + withPython ? true, + withExtras ? true, + Carbon, + Cocoa, }: assert withGTK -> withGUI; @@ -46,16 +67,39 @@ stdenv.mkDerivation rec { # do not use x87's 80-bit arithmetic, rouding errors result in very different font binaries env.NIX_CFLAGS_COMPILE = lib.optionalString stdenv.hostPlatform.isi686 "-msse2 -mfpmath=sse"; - nativeBuildInputs = [ pkg-config cmake ]; - buildInputs = [ - readline uthash woff2 zeromq - python freetype zlib glib giflib libpng libjpeg libtiff libxml2 - ] + nativeBuildInputs = [ + pkg-config + cmake + ]; + buildInputs = + [ + readline + uthash + woff2 + zeromq + python + freetype + zlib + glib + giflib + libpng + libjpeg + libtiff + libxml2 + ] ++ lib.optionals withSpiro [ libspiro ] - ++ lib.optionals withGUI [ gtk3 cairo pango ] - ++ lib.optionals stdenv.hostPlatform.isDarwin [ Carbon Cocoa ]; + ++ lib.optionals withGUI [ + gtk3 + cairo + pango + ] + ++ lib.optionals stdenv.hostPlatform.isDarwin [ + Carbon + Cocoa + ]; - cmakeFlags = [ "-DCMAKE_BUILD_WITH_INSTALL_RPATH=ON" ] + cmakeFlags = + [ "-DCMAKE_BUILD_WITH_INSTALL_RPATH=ON" ] ++ lib.optional (!withSpiro) "-DENABLE_LIBSPIRO=OFF" ++ lib.optional (!withGUI) "-DENABLE_GUI=OFF" ++ lib.optional (!withGTK) "-DENABLE_X11=ON" From 06fc75a3a4424d3748521a3c12e156845f336745 Mon Sep 17 00:00:00 2001 From: Ulysses Zhan Date: Wed, 13 Nov 2024 17:13:48 -0800 Subject: [PATCH 2/2] fontforge: fix error: Core python package 'pkg_resources' not found: Cannot discover plugins --- pkgs/tools/misc/fontforge/default.nix | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/pkgs/tools/misc/fontforge/default.nix b/pkgs/tools/misc/fontforge/default.nix index 045cabc09d0a..364bccfacbd8 100644 --- a/pkgs/tools/misc/fontforge/default.nix +++ b/pkgs/tools/misc/fontforge/default.nix @@ -29,10 +29,14 @@ withExtras ? true, Carbon, Cocoa, + makeWrapper, }: assert withGTK -> withGUI; +let + py = python.withPackages (ps: with ps; [ setuptools ]); +in stdenv.mkDerivation rec { pname = "fontforge"; version = "20230101"; @@ -70,6 +74,7 @@ stdenv.mkDerivation rec { nativeBuildInputs = [ pkg-config cmake + makeWrapper ]; buildInputs = [ @@ -77,7 +82,7 @@ stdenv.mkDerivation rec { uthash woff2 zeromq - python + py freetype zlib glib @@ -111,16 +116,20 @@ stdenv.mkDerivation rec { ''; postInstall = - # get rid of the runtime dependency on python - lib.optionalString (!withPython) '' - rm -r "$out/share/fontforge/python" - ''; + '' + wrapProgram $out/bin/fontforge --suffix PYTHONPATH : "${py}/${py.sitePackages}" + '' + + + # get rid of the runtime dependency on python + lib.optionalString (!withPython) '' + rm -r "$out/share/fontforge/python" + ''; meta = with lib; { description = "Font editor"; homepage = "https://fontforge.github.io"; platforms = platforms.all; license = licenses.bsd3; - maintainers = [ maintainers.erictapen ]; + maintainers = with maintainers; [ erictapen ulysseszhan ]; }; }