{libGL,libGLU}: use the OpenGL framework on Darwin

This reduces the reverse closure of Mesa on Darwin considerably. As
a result, we can also drop the Mesa stubs package entirely, as its
output on Linux is functionally identical to libglvnd.

It should no longer be necessary for packages to switch between libGL
and darwin.apple_sdk.frameworks.OpenGL depending on the platform.

A cross‐platform libGLX alias is added for packages that specifically
need it (mostly old X11 applications that barely know what a macOS is).

Co-authored-by: K900 <me@0upti.me>
This commit is contained in:
Emily
2024-06-22 08:33:02 +01:00
parent 762fadc42f
commit 755c400a92
+34 -9
View File
@@ -23210,16 +23210,41 @@ with pkgs;
## libGL/libGLU/Mesa stuff
# Default libGL implementation, should provide headers and
# libGL.so/libEGL.so/... to link agains them. Android NDK provides
# an OpenGL implementation, we can just use that.
libGL = if stdenv.hostPlatform.useAndroidPrebuilt then stdenv
else callPackage ../development/libraries/mesa/stubs.nix {
inherit (darwin.apple_sdk.frameworks) OpenGL;
};
# Default libGL implementation.
#
# Android NDK provides an OpenGL implementation, we can just use that.
#
# On macOS, we use the OpenGL framework. Packages that still need GLX
# specifically can pull in libGLX instead. If you have a package that
# should work without X11 but it cant find the library, it may help
# to add the path to `NIX_CFLAGS_COMPILE`:
#
# -L${libGL}/Library/Frameworks/OpenGL.framework/Versions/Current/Libraries
#
# If you still cant get it working, please dont hesitate to ping
# @NixOS/darwin-maintainers to ask an expert to take a look.
libGL =
if stdenv.hostPlatform.useAndroidPrebuilt then
stdenv
else if stdenv.hostPlatform.isDarwin then
darwin.apple_sdk.frameworks.OpenGL
else
libglvnd;
# Default libGLU
libGLU = mesa_glu;
# On macOS, we use the OpenGL framework. Packages that use libGLX on
# macOS may need to depend on mesa_glu directly if this doesnt work.
libGLU =
if stdenv.hostPlatform.isDarwin then
darwin.apple_sdk.frameworks.OpenGL
else
mesa_glu;
# libglvnd does not work (yet?) on macOS.
libGLX =
if stdenv.hostPlatform.isDarwin then
mesa
else
libglvnd;
mesa = if stdenv.isDarwin
then darwin.apple_sdk_11_0.callPackage ../development/libraries/mesa/darwin.nix {