8 stdenv.mkDerivation (finalAttrs: {
10 inherit (if stdenv.hostPlatform.isDarwin then mesa else libglvnd) version;
11 outputs = [ "out" "dev" ];
13 # On macOS, libglvnd is not supported, so we just use what mesa
14 # build. We need to also include OpenGL.framework, and some
15 # extra tricks to go along with. We add mesa’s libGLX to support
16 # the X extensions to OpenGL.
17 buildCommand = if stdenv.hostPlatform.isDarwin then ''
18 mkdir -p $out/nix-support $dev
19 echo ${OpenGL} >> $out/nix-support/propagated-build-inputs
20 ln -s ${mesa.out}/lib $out/lib
22 mkdir -p $dev/lib/pkgconfig $dev/nix-support
23 echo "$out" > $dev/nix-support/propagated-build-inputs
24 ln -s ${mesa.dev}/include $dev/include
26 cat <<EOF >$dev/lib/pkgconfig/gl.pc
28 Description: gl library
29 Version: ${mesa.version}
30 Libs: -L${mesa.out}/lib -lGL
31 Cflags: -I${mesa.dev}/include
34 cat <<EOF >$dev/lib/pkgconfig/glesv1_cm.pc
36 Description: glesv1_cm library
37 Version: ${mesa.version}
38 Libs: -L${mesa.out}/lib -lGLESv1_CM
39 Cflags: -I${mesa.dev}/include
42 cat <<EOF >$dev/lib/pkgconfig/glesv2.pc
44 Description: glesv2 library
45 Version: ${mesa.version}
46 Libs: -L${mesa.out}/lib -lGLESv2
47 Cflags: -I${mesa.dev}/include
51 # Otherwise, setup gl stubs to use libglvnd.
53 mkdir -p $out/nix-support
54 ln -s ${libglvnd.out}/lib $out/lib
56 mkdir -p $dev/{,lib/pkgconfig,nix-support}
57 echo "$out ${libglvnd} ${libglvnd.dev}" > $dev/nix-support/propagated-build-inputs
58 ln -s ${libglvnd.dev}/include $dev/include
64 cat <<EOF >$dev/lib/pkgconfig/$name.pc
66 Description: $lib library
67 Version: ${libglvnd.version}
68 Libs: -L${libglvnd.out}/lib -l$lib
69 Cflags: -I${libglvnd.dev}/include
75 genPkgConfig glesv1_cm GLESv1_CM
76 genPkgConfig glesv2 GLESv2
79 passthru.tests.pkg-config = testers.testMetaPkgConfig finalAttrs.finalPackage;
82 description = "Stub bindings using " + (if stdenv.hostPlatform.isDarwin then "mesa" else "libglvnd");
83 pkgConfigModules = [ "gl" "egl" "glesv1_cm" "glesv2" ];
85 inherit (if stdenv.hostPlatform.isDarwin then mesa.meta else libglvnd.meta) homepage license platforms;