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