diff --git a/pkgs/opengl/default.nix b/pkgs/opengl/default.nix index 88f3b60..ccc2b76 100644 --- a/pkgs/opengl/default.nix +++ b/pkgs/opengl/default.nix @@ -1,11 +1,11 @@ # This override makes OpenGL just automagically work with VirtualGL # -# Add a setup hook to the mesa_noglu package that automatically adds -# a libvglfaker.so dependency to executables that depend on libGL.so. +# Add a setup hook to the mesa package that automatically adds a +# libvglfaker.so dependency to executables that depend on libGL.so. { super, stdenv, buildEnv, substituteAll, bash , autoreconfHook, pkgconfig, python2 -, xorg, llvmPackages, expat, mesa_glxgallium, mesa_noglu, libglvnd }: +, xorg, llvmPackages, expat, mesa_glxgallium, mesa, libglvnd }: let autoVirtualGLHook = @@ -23,7 +23,7 @@ let extraOutputsToInstall = [ "dev" ]; }; - virtualglLib = (super.virtualglLib.override { inherit libGLU_combined fltk; }).overrideAttrs (attrs: { + virtualglLib = (super.virtualglLib.override { inherit libGL libGLU fltk; }).overrideAttrs (attrs: { postFixup = attrs.postFixup or "" + '' patchelf --set-rpath /usr/lib${stdenv.lib.optionalString stdenv.is64bit "64"}/nvidia:"$(patchelf --print-rpath $out/lib/libvglfaker.so)" $out/lib/libvglfaker.so ''; @@ -41,52 +41,31 @@ in { # Mesa build for glxgallium software rendering (works with all X11 forwarding) - mesa_glxgallium = stdenv.mkDerivation rec { - version = super.mesa_noglu.version; - name = "mesa-glxgallium-${version}"; - src = super.mesa_noglu.src; - - outputs = [ "out" "dev" ]; - - configureFlags = [ - "--with-gallium-drivers=swrast" - "--with-platforms=x11" # surfaceless would make sense, but egl requires dri - "--disable-dri" - "--enable-glx=gallium-xlib" # gallium-xlib requires no dri - "--enable-gallium-osmesa" - "--enable-llvm" - "--disable-egl" # egl requries dri for some reason - "--disable-gbm" # gbm requires dri for some reason - "--enable-llvm-shared-libs" - "--disable-opencl" + mesa_glxgallium = mesa.overrideAttrs (attrs: { + mesonFlags = attrs.mesonFlags ++ [ + "-Dglx=gallium-xlib" + "-Ddri-drivers=" + "-Dgallium-drivers=swrast" + "-Dglvnd=false" + "-Dgallium-nine=false" ]; - nativeBuildInputs = [ - autoreconfHook pkgconfig - python2 - ]; - propagatedBuildInputs = [ ]; - buildInputs = [ - llvmPackages.llvm - xorg.xorgproto xorg.libX11 xorg.libXext xorg.libxcb - expat - ]; + # No dri drivers so need to drop all the "drivers" output code (ignoring vulkan for now) + outputs = [ "out" "dev" "osmesa" ]; - enableParallelBuilding = true; + postInstall = '' + # move libOSMesa to $osmesa, as it's relatively big + mkdir -p $osmesa/lib + mv -t $osmesa/lib/ $out/lib/libOSMesa* + ''; + postFixup = ""; + } ); - meta = with stdenv.lib; { - description = "An open source implementation of OpenGL"; - homepage = https://www.mesa3d.org/; - license = licenses.mit; # X11 variant, in most files - platforms = platforms.linux; - }; - }; - - - # Duplicate mesa_noglu.stub with mesa_glxgallium stuffed in as the libGL source + # Duplicate mesa/stubs.nix with mesa_glxgallium stuffed in as the libGL source libGL = stdenv.mkDerivation { - name = "libGL-${libglvnd.version}"; + inherit (libglvnd) version; + pname = "libGL"; outputs = [ "out" "dev" ]; nativeBuildInputs = [ xorg.lndir ]; @@ -100,7 +79,7 @@ in { mkdir -p $dev/{,lib/pkgconfig,nix-support} echo "$out" > $dev/nix-support/propagated-build-inputs echo ${autoVirtualGLHook} >> $dev/nix-support/propagated-build-inputs - ln -s ${mesa_noglu.dev}/include $dev/include + ln -s ${mesa.dev}/include $dev/include genPkgConfig() { local location="$1" @@ -110,16 +89,16 @@ in { cat <$dev/lib/pkgconfig/$name.pc Name: $name Description: $lib library - Version: ${mesa_noglu.version} + Version: ${mesa.version} Libs: -L$location/lib -l$lib - Cflags: -I${mesa_noglu.dev}/include + Cflags: -I${mesa.dev}/include EOF } genPkgConfig ${mesa_glxgallium.out} gl GL genPkgConfig ${libglvnd.out} egl EGL - genPkgConfig ${libglvnd.out} glesv1_cm GLESv1_CM - genPkgConfig ${libglvnd.out} glesv2 GLESv2 + genPkgConfig ${mesa_glxgallium.out} glesv1_cm GLESv1_CM + genPkgConfig ${mesa_glxgallium.out} glesv2 GLESv2 ''; }; }