Files
ccpkgs/pkgs/opengl/default.nix
2019-05-02 11:54:43 -04:00

43 lines
1.4 KiB
Nix

# 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.
{ super, lib, buildEnv, makeSetupHook, file, bash, xorg }:
let
autoVirtualGLHook =
let
# Ugliness required to break the loop created by the fact that
# the libGL hook requires VirtualGL which requires libGL.
#
# This would be clean if super was closed on itself (nixpkgs #15280)
libGL = super.libGL;
libGLU = super.libGLU.override { inherit libGL; };
libGLU_combined = (buildEnv {
name = "libGLU-combined";
paths = [ libGL libGLU ];
extraOutputsToInstall = [ "dev" ];
});
virtualglLib = (super.virtualglLib.override { inherit libGLU_combined fltk; });
fltk = super.fltk.override { inherit libGLU_combined freeglut; };
freeglut = super.freeglut.override { inherit libGL libGLU; };
in
makeSetupHook {
name = "insert-virtualgl";
deps = [ file virtualglLib ];
substitutions = { inherit virtualglLib bash; inherit (xorg) libXext; };
} ./insert-virtualgl.sh;
in {
libGL = super.libGL.overrideAttrs ( attrs: {
# Done as a non-standard build command, so have to add it in this way
buildCommand = attrs.buildCommand + ''
echo '${autoVirtualGLHook}' >> $dev/nix-support/propagated-build-inputs
'';
} );
}