about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/libraries/libepoxy/default.nix
blob: c54c3c86d232b4cec5586aa2928e3ea591a68acf (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
{ lib
, stdenv
, fetchFromGitHub
, meson
, ninja
, pkg-config
, utilmacros
, python3
, libGL
, libX11
, Carbon
, OpenGL
, x11Support ? !stdenv.isDarwin
}:

let
  inherit (lib) getLib optional optionalString;

in
stdenv.mkDerivation rec {
  pname = "libepoxy";
  version = "1.5.9";

  src = fetchFromGitHub {
    owner = "anholt";
    repo = pname;
    rev = version;
    sha256 = "sha256-8rdmC8FZUkKkEvWPJIdfrBQHiwa81vl5tmVqRdU4UIY=";
  };

  patches = [ ./libgl-path.patch ];

  postPatch = ''
    patchShebangs src/*.py
  ''
  + optionalString stdenv.isDarwin ''
    substituteInPlace src/dispatch_common.h --replace "PLATFORM_HAS_GLX 0" "PLATFORM_HAS_GLX 1"
  '';

  outputs = [ "out" "dev" ];

  nativeBuildInputs = [ meson ninja pkg-config utilmacros python3 ];

  buildInputs = lib.optionals x11Support [
    libGL
    libX11
  ] ++ lib.optionals stdenv.isDarwin [
    Carbon
    OpenGL
  ];

  mesonFlags = [
    "-Dtests=${if doCheck then "true" else "false"}"
    "-Dglx=${if x11Support then "yes" else "no"}"
  ];

  NIX_CFLAGS_COMPILE = lib.optionalString x11Support ''-DLIBGL_PATH="${getLib libGL}/lib"'';

  # cgl_epoxy_api fails in darwin sandbox and on Hydra (because it's headless?)
  preCheck = lib.optionalString stdenv.isDarwin ''
    substituteInPlace ../test/meson.build \
      --replace "[ 'cgl_epoxy_api', [ 'cgl_epoxy_api.c' ] ]," ""
  '';

  # tests are running from version 1.5.9
  doCheck = true;

  meta = with lib; {
    description = "A library for handling OpenGL function pointer management";
    homepage = "https://github.com/anholt/libepoxy";
    license = licenses.mit;
    maintainers = with maintainers; [ goibhniu erictapen ];
    platforms = platforms.unix;
  };
}