nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at 20.09 75 lines 2.0 kB view raw
1{ stdenv 2, libglvnd, mesa 3, OpenGL }: 4 5stdenv.mkDerivation { 6 inherit (libglvnd) version; 7 pname = "libGL"; 8 outputs = [ "out" "dev" ]; 9 10 # On macOS, libglvnd is not supported, so we just use what mesa 11 # build. We need to also include OpenGL.framework, and some 12 # extra tricks to go along with. We add mesa’s libGLX to support 13 # the X extensions to OpenGL. 14 buildCommand = if stdenv.hostPlatform.isDarwin then '' 15 mkdir -p $out/nix-support $dev 16 echo ${OpenGL} >> $out/nix-support/propagated-build-inputs 17 ln -s ${mesa.out}/lib $out/lib 18 19 mkdir -p $dev/lib/pkgconfig $dev/nix-support 20 echo "$out" > $dev/nix-support/propagated-build-inputs 21 ln -s ${mesa.dev}/include $dev/include 22 23 cat <<EOF >$dev/lib/pkgconfig/gl.pc 24 Name: gl 25 Description: gl library 26 Version: ${mesa.version} 27 Libs: -L${mesa.out}/lib -lGL 28 Cflags: -I${mesa.dev}/include 29 EOF 30 31 cat <<EOF >$dev/lib/pkgconfig/glesv1_cm.pc 32 Name: glesv1_cm 33 Description: glesv1_cm library 34 Version: ${mesa.version} 35 Libs: -L${mesa.out}/lib -lGLESv1_CM 36 Cflags: -I${mesa.dev}/include 37 EOF 38 39 cat <<EOF >$dev/lib/pkgconfig/glesv2.pc 40 Name: glesv2 41 Description: glesv2 library 42 Version: ${mesa.version} 43 Libs: -L${mesa.out}/lib -lGLESv2 44 Cflags: -I${mesa.dev}/include 45 EOF 46 '' 47 48 # Otherwise, setup gl stubs to use libglvnd. 49 else '' 50 mkdir -p $out/nix-support 51 ln -s ${libglvnd.out}/lib $out/lib 52 53 mkdir -p $dev/{,lib/pkgconfig,nix-support} 54 echo "$out ${libglvnd} ${libglvnd.dev}" > $dev/nix-support/propagated-build-inputs 55 ln -s ${mesa.dev}/include $dev/include 56 57 genPkgConfig() { 58 local name="$1" 59 local lib="$2" 60 61 cat <<EOF >$dev/lib/pkgconfig/$name.pc 62 Name: $name 63 Description: $lib library 64 Version: ${mesa.version} 65 Libs: -L${libglvnd.out}/lib -l$lib 66 Cflags: -I${mesa.dev}/include -I${libglvnd.dev}/include 67 EOF 68 } 69 70 genPkgConfig gl GL 71 genPkgConfig egl EGL 72 genPkgConfig glesv1_cm GLESv1_CM 73 genPkgConfig glesv2 GLESv2 74 ''; 75}