Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ stdenv, lib, fetchFromGitLab 2, autoreconfHook, pkg-config, python3, addOpenGLRunpath 3, libX11, libXext, xorgproto 4}: 5 6stdenv.mkDerivation rec { 7 pname = "libglvnd"; 8 version = "1.6.0"; 9 10 src = fetchFromGitLab { 11 domain = "gitlab.freedesktop.org"; 12 owner = "glvnd"; 13 repo = "libglvnd"; 14 rev = "v${version}"; 15 sha256 = "sha256-p/vLxagN9nCYw1JpUmZetgctQbrp3Wo33OVFrtvmnjQ="; 16 }; 17 18 nativeBuildInputs = [ autoreconfHook pkg-config python3 addOpenGLRunpath ]; 19 buildInputs = [ libX11 libXext xorgproto ]; 20 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" 28 ''; 29 30 env.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\"" 34 35 "-Wno-error=array-bounds" 36 ] ++ lib.optional stdenv.cc.isClang "-Wno-error"); 37 38 configureFlags = [] 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"; 43 44 outputs = [ "out" "dev" ]; 45 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. 49 postFixup = '' 50 addOpenGLRunpath $out/lib/libGLX.so 51 ''; 52 53 passthru = { inherit (addOpenGLRunpath) driverLink; }; 54 55 meta = with lib; { 56 description = "The GL Vendor-Neutral Dispatch library"; 57 longDescription = '' 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. 63 ''; 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.unix; 69 maintainers = with maintainers; [ primeos ]; 70 }; 71}