Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at flake-libs 84 lines 2.2 kB view raw
1{ 2 lib, 3 stdenv, 4 llvmPackages, 5 fetchurl, 6 pkg-config, 7 freetype, 8 cmake, 9 static ? stdenv.hostPlatform.isStatic, 10 testers, 11}: 12 13stdenv.mkDerivation (finalAttrs: { 14 version = "1.3.14"; 15 pname = "graphite2"; 16 17 src = fetchurl { 18 url = 19 with finalAttrs; 20 "https://github.com/silnrsi/graphite/releases/download/${version}/${pname}-${version}.tgz"; 21 sha256 = "1790ajyhk0ax8xxamnrk176gc9gvhadzy78qia4rd8jzm89ir7gr"; 22 }; 23 24 outputs = [ 25 "out" 26 "dev" 27 ]; 28 29 nativeBuildInputs = [ 30 pkg-config 31 cmake 32 ]; 33 buildInputs = 34 [ freetype ] 35 ++ lib.optional (stdenv.targetPlatform.useLLVM or false) ( 36 llvmPackages.compiler-rt.override { 37 doFakeLibgcc = true; 38 } 39 ); 40 41 patches = lib.optionals stdenv.hostPlatform.isDarwin [ ./macosx.patch ]; 42 postPatch = '' 43 # disable broken 'nametabletest' test, fails on gcc-13: 44 # https://github.com/silnrsi/graphite/pull/74 45 substituteInPlace tests/CMakeLists.txt \ 46 --replace 'add_subdirectory(nametabletest)' '#add_subdirectory(nametabletest)' 47 48 # support cross-compilation by using target readelf binary: 49 substituteInPlace Graphite.cmake \ 50 --replace 'readelf' "${stdenv.cc.targetPrefix}readelf" 51 52 # headers are located in the dev output: 53 substituteInPlace CMakeLists.txt \ 54 --replace-fail ' ''${CMAKE_INSTALL_PREFIX}/include' " ${placeholder "dev"}/include" 55 ''; 56 57 cmakeFlags = lib.optionals static [ 58 "-DBUILD_SHARED_LIBS=OFF" 59 ]; 60 61 # Remove a test that fails to statically link (undefined reference to png and 62 # freetype symbols) 63 postConfigure = lib.optionalString static '' 64 sed -e '/freetype freetype.c/d' -i ../tests/examples/CMakeLists.txt 65 ''; 66 67 doCheck = true; 68 69 passthru.tests = { 70 pkg-config = testers.hasPkgConfigModules { 71 package = finalAttrs.finalPackage; 72 }; 73 }; 74 75 meta = with lib; { 76 description = "Advanced font engine"; 77 homepage = "https://graphite.sil.org/"; 78 license = licenses.lgpl21; 79 maintainers = [ maintainers.raskin ]; 80 pkgConfigModules = [ "graphite2" ]; 81 mainProgram = "gr2fonttest"; 82 platforms = platforms.unix ++ platforms.windows; 83 }; 84})