about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/libraries/epoxy
diff options
context:
space:
mode:
Diffstat (limited to 'nixpkgs/pkgs/development/libraries/epoxy')
-rw-r--r--nixpkgs/pkgs/development/libraries/epoxy/default.nix41
-rw-r--r--nixpkgs/pkgs/development/libraries/epoxy/libgl-path.patch24
2 files changed, 65 insertions, 0 deletions
diff --git a/nixpkgs/pkgs/development/libraries/epoxy/default.nix b/nixpkgs/pkgs/development/libraries/epoxy/default.nix
new file mode 100644
index 000000000000..7ae0e73953f4
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/epoxy/default.nix
@@ -0,0 +1,41 @@
+{ lib, stdenv, fetchFromGitHub, autoreconfHook, pkg-config, utilmacros, python3
+, libGL, libX11
+}:
+
+with lib;
+
+stdenv.mkDerivation rec {
+  pname = "epoxy";
+  version = "1.5.4";
+
+  src = fetchFromGitHub {
+    owner = "anholt";
+    repo = "libepoxy";
+    rev = version;
+    sha256 = "0rmg0qlswn250h0arx434jh3hwzsr95lawanpmh1czsfvrcx59l6";
+  };
+
+  outputs = [ "out" "dev" ];
+
+  nativeBuildInputs = [ autoreconfHook pkg-config utilmacros python3 ];
+  buildInputs = [ libGL libX11 ];
+
+  preConfigure = optionalString stdenv.isDarwin ''
+    substituteInPlace configure --replace build_glx=no build_glx=yes
+    substituteInPlace src/dispatch_common.h --replace "PLATFORM_HAS_GLX 0" "PLATFORM_HAS_GLX 1"
+  '';
+
+  patches = [ ./libgl-path.patch ];
+
+  NIX_CFLAGS_COMPILE = ''-DLIBGL_PATH="${getLib libGL}/lib"'';
+
+  doCheck = false; # needs X11
+
+  meta = {
+    description = "A library for handling OpenGL function pointer management";
+    homepage = "https://github.com/anholt/libepoxy";
+    license = licenses.mit;
+    maintainers = [ maintainers.goibhniu ];
+    platforms = platforms.unix;
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/epoxy/libgl-path.patch b/nixpkgs/pkgs/development/libraries/epoxy/libgl-path.patch
new file mode 100644
index 000000000000..8f38ee27174b
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/epoxy/libgl-path.patch
@@ -0,0 +1,24 @@
+diff --git a/src/dispatch_common.c b/src/dispatch_common.c
+index b3e4f5f..303e8f5 100644
+--- a/src/dispatch_common.c
++++ b/src/dispatch_common.c
+@@ -310,6 +310,19 @@ get_dlopen_handle(void **handle, const char *lib_name, bool exit_on_fail, bool l
+             flags |= RTLD_NOLOAD;
+ 
+         *handle = dlopen(lib_name, flags);
++#ifdef LIBGL_PATH
++        if (!*handle) {
++          char pathbuf[sizeof(LIBGL_PATH) + 1 + 1024 + 1];
++          int l = snprintf(pathbuf, sizeof(pathbuf), "%s/%s", LIBGL_PATH, lib_name);
++          if (l < 0 || l >= sizeof(pathbuf)) {
++            // This really shouldn't happen
++            fprintf(stderr, "Error prefixing library pathname\n");
++            exit(1);
++          }
++          *handle = dlopen(pathbuf, flags);
++        }
++#endif
++
+         if (!*handle) {
+             if (exit_on_fail) {
+                 fprintf(stderr, "Couldn't open %s: %s\n", lib_name, dlerror());