1 { stdenv, lib, fetchFromGitLab
2 , autoreconfHook, pkg-config, python3, addOpenGLRunpath
3 , libX11, libXext, xorgproto
6 stdenv.mkDerivation rec {
10 src = fetchFromGitLab {
11 domain = "gitlab.freedesktop.org";
15 sha256 = "sha256-yXSuG8UwD5KZbn4ysDStTdOGD4uHigjOhazlHT9ndNs=";
18 nativeBuildInputs = [ autoreconfHook pkg-config python3 addOpenGLRunpath ];
19 buildInputs = [ libX11 libXext xorgproto ];
21 postPatch = lib.optionalString stdenv.isDarwin ''
22 substituteInPlace src/GLX/Makefile.am \
23 --replace "-Wl,-Bsymbolic " ""
24 substituteInPlace src/EGL/Makefile.am \
25 --replace "-Wl,-Bsymbolic " ""
26 substituteInPlace src/GLdispatch/Makefile.am \
27 --replace "-Xlinker --version-script=$(VERSION_SCRIPT)" "-Xlinker"
30 NIX_CFLAGS_COMPILE = toString ([
31 "-UDEFAULT_EGL_VENDOR_CONFIG_DIRS"
32 # FHS paths are added so that non-NixOS applications can find vendor files.
33 "-DDEFAULT_EGL_VENDOR_CONFIG_DIRS=\"${addOpenGLRunpath.driverLink}/share/glvnd/egl_vendor.d:/etc/glvnd/egl_vendor.d:/usr/share/glvnd/egl_vendor.d\""
35 "-Wno-error=array-bounds"
36 ] ++ lib.optional stdenv.cc.isClang "-Wno-error");
39 # Indirectly: https://bugs.freedesktop.org/show_bug.cgi?id=35268
40 ++ lib.optional stdenv.hostPlatform.isMusl "--disable-tls"
41 # Remove when aarch64-darwin asm support is upstream: https://gitlab.freedesktop.org/glvnd/libglvnd/-/issues/216
42 ++ lib.optional (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isAarch64) "--disable-asm";
44 outputs = [ "out" "dev" ];
46 # Set RUNPATH so that libGLX can find driver libraries in /run/opengl-driver(-32)/lib.
47 # Note that libEGL does not need it because it uses driver config files which should
48 # contain absolute paths to libraries.
50 addOpenGLRunpath $out/lib/libGLX.so
53 passthru = { inherit (addOpenGLRunpath) driverLink; };
56 description = "The GL Vendor-Neutral Dispatch library";
58 libglvnd is a vendor-neutral dispatch layer for arbitrating OpenGL API
59 calls between multiple vendors. It allows multiple drivers from different
60 vendors to coexist on the same filesystem, and determines which vendor to
61 dispatch each API call to at runtime.
62 Both GLX and EGL are supported, in any combination with OpenGL and OpenGL ES.
64 inherit (src.meta) homepage;
65 # https://gitlab.freedesktop.org/glvnd/libglvnd#libglvnd:
66 changelog = "https://gitlab.freedesktop.org/glvnd/libglvnd/-/tags/v${version}";
67 license = with licenses; [ mit bsd1 bsd3 gpl3Only asl20 ];
68 platforms = platforms.linux ++ platforms.darwin;
69 maintainers = with maintainers; [ primeos ];