Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ 2 lib, 3 stdenv, 4 fetchFromGitHub, 5 meson, 6 ninja, 7 pkg-config, 8 utilmacros, 9 python3, 10 libGL, 11 libX11, 12 x11Support ? !stdenv.hostPlatform.isDarwin, 13 testers, 14}: 15 16stdenv.mkDerivation (finalAttrs: { 17 pname = "libepoxy"; 18 version = "1.5.10"; 19 20 src = 21 with finalAttrs; 22 fetchFromGitHub { 23 owner = "anholt"; 24 repo = "libepoxy"; 25 rev = version; 26 sha256 = "sha256-gZiyPOW2PeTMILcPiUTqPUGRNlMM5mI1z9563v4SgEs="; 27 }; 28 29 patches = [ ./libgl-path.patch ]; 30 31 postPatch = '' 32 patchShebangs src/*.py 33 '' 34 + lib.optionalString stdenv.hostPlatform.isDarwin '' 35 substituteInPlace src/dispatch_common.h --replace-fail "PLATFORM_HAS_GLX 0" "PLATFORM_HAS_GLX 1" 36 '' 37 # cgl_core and cgl_epoxy_api fail in darwin sandbox and on Hydra (because it's headless?) 38 + lib.optionalString stdenv.hostPlatform.isDarwin '' 39 substituteInPlace test/meson.build \ 40 --replace-fail "[ 'cgl_core', [ 'cgl_core.c' ] ]," "" \ 41 --replace-fail "[ 'cgl_epoxy_api', [ 'cgl_epoxy_api.c' ] ]," "" 42 ''; 43 44 outputs = [ 45 "out" 46 "dev" 47 ]; 48 49 nativeBuildInputs = [ 50 meson 51 ninja 52 pkg-config 53 utilmacros 54 python3 55 ]; 56 57 propagatedBuildInputs = 58 lib.optionals (x11Support && !stdenv.hostPlatform.isDarwin) [ 59 libGL 60 ] 61 ++ lib.optionals x11Support [ 62 libX11 63 ]; 64 65 mesonFlags = [ 66 "-Degl=${if (x11Support && !stdenv.hostPlatform.isDarwin) then "yes" else "no"}" 67 "-Dglx=${if x11Support then "yes" else "no"}" 68 "-Dtests=${lib.boolToString finalAttrs.finalPackage.doCheck}" 69 "-Dx11=${lib.boolToString x11Support}" 70 ]; 71 72 env.NIX_CFLAGS_COMPILE = lib.optionalString ( 73 x11Support && !stdenv.hostPlatform.isDarwin 74 ) ''-DLIBGL_PATH="${lib.getLib libGL}/lib"''; 75 76 doCheck = true; 77 78 passthru.tests = { 79 pkg-config = testers.hasPkgConfigModules { 80 package = finalAttrs.finalPackage; 81 }; 82 }; 83 84 meta = with lib; { 85 description = "Library for handling OpenGL function pointer management"; 86 homepage = "https://github.com/anholt/libepoxy"; 87 license = licenses.mit; 88 maintainers = [ ]; 89 platforms = platforms.unix; 90 pkgConfigModules = [ "epoxy" ]; 91 }; 92})