Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
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 ] 36 ++ lib.optional (stdenv.targetPlatform.useLLVM or false) ( 37 llvmPackages.compiler-rt.override { 38 doFakeLibgcc = true; 39 } 40 ); 41 42 patches = lib.optionals stdenv.hostPlatform.isDarwin [ ./macosx.patch ]; 43 postPatch = '' 44 # disable broken 'nametabletest' test, fails on gcc-13: 45 # https://github.com/silnrsi/graphite/pull/74 46 substituteInPlace tests/CMakeLists.txt \ 47 --replace 'add_subdirectory(nametabletest)' '#add_subdirectory(nametabletest)' 48 49 # support cross-compilation by using target readelf binary: 50 substituteInPlace Graphite.cmake \ 51 --replace 'readelf' "${stdenv.cc.targetPrefix}readelf" 52 53 # headers are located in the dev output: 54 substituteInPlace CMakeLists.txt \ 55 --replace-fail ' ''${CMAKE_INSTALL_PREFIX}/include' " ${placeholder "dev"}/include" 56 ''; 57 58 cmakeFlags = lib.optionals static [ 59 "-DBUILD_SHARED_LIBS=OFF" 60 ]; 61 62 # Remove a test that fails to statically link (undefined reference to png and 63 # freetype symbols) 64 postConfigure = lib.optionalString static '' 65 sed -e '/freetype freetype.c/d' -i ../tests/examples/CMakeLists.txt 66 ''; 67 68 doCheck = true; 69 70 passthru.tests = { 71 pkg-config = testers.hasPkgConfigModules { 72 package = finalAttrs.finalPackage; 73 }; 74 }; 75 76 meta = with lib; { 77 description = "Advanced font engine"; 78 homepage = "https://graphite.sil.org/"; 79 license = licenses.lgpl21; 80 maintainers = [ maintainers.raskin ]; 81 pkgConfigModules = [ "graphite2" ]; 82 mainProgram = "gr2fonttest"; 83 platforms = platforms.unix ++ platforms.windows; 84 }; 85})