@@ -1,12 +1,13 @@
1−{ stdenv, fetchurl, fetchpatch
2−, pkgconfig, intltool, autoreconfHook, substituteAll
3−, file, expat, libdrm, xorg, wayland, libudev
4−, llvmPackages, libffi, libomxil-bellagio, libva
5−, libelf, libvdpau, python
6−, grsecEnabled ? false
1+{ stdenv, fetchurl, fetchpatch, pkgconfig, intltool, autoreconfHook, substituteAll
2+, file, expat, libdrm, xorg, wayland, libudev, llvmPackages, libffi, libomxil-bellagio
3+, libvdpau, libelf, libva
4+, grsecEnabled
75, enableTextureFloats ? false # Texture floats are patented, see docs/patents.txt
86}:
97
8+if ! stdenv.lib.lists.elem stdenv.system stdenv.lib.platforms.mesaPlatforms then
9+ throw "unsupported platform for Mesa"
10+else
1011
1112/** Packaging design:
1213 - The basic mesa ($out) contains headers and libraries (GLU is in mesa_glu now).
@@ -19,15 +20,11 @@
1920 - libOSMesa is in $osmesa (~4 MB)
2021*/
2122
22−with stdenv.lib;
23−
24−if ! lists.elem stdenv.system platforms.mesaPlatforms then
25− throw "unsupported platform for Mesa"
26−else
23+with { inherit (stdenv.lib) optional optionalString; };
2724
2825let
29− version = "12.0.1";
30− branch = head (splitString "." version);
26+ version = "11.2.2";
27+ # this is the default search path for DRI drivers
3128 driverLink = "/run/opengl-driver" + optionalString stdenv.isi686 "-32";
3229in
3330
@@ -37,20 +34,20 @@ stdenv.mkDerivation {
3734 src = fetchurl {
3835 urls = [
3936 "ftp://ftp.freedesktop.org/pub/mesa/${version}/mesa-${version}.tar.xz"
40− "ftp://ftp.freedesktop.org/pub/mesa/older-versions/${branch}.x/${version}/mesa-${version}.tar.xz"
37+ (with stdenv.lib; ''ftp://ftp.freedesktop.org/pub/mesa/older-versions/''
38+ + head (splitString "." version) + ''.x/${version}/mesa-${version}.tar.xz'')
4139 "https://launchpad.net/mesa/trunk/${version}/+download/mesa-${version}.tar.xz"
4240 ];
43− sha256 = "12b3i59xdn2in2hchrkgh4fwij8zhznibx976l3pdj3qkyvlzcms";
41+ sha256 = "40e148812388ec7c6d7b6657d5a16e2e8dabba8b97ddfceea5197947647bdfb4";
4442 };
4543
4644 prePatch = "patchShebangs .";
4745
48− # TODO:
49− # revive ./dricore-gallium.patch when it gets ported (from Ubuntu), as it saved
50− # ~35 MB in $drivers; watch https://launchpad.net/ubuntu/+source/mesa/+changelog
5146 patches = [
5247 ./glx_ro_text_segm.patch # fix for grsecurity/PaX
5348 ./symlink-drivers.patch
49+ # TODO: revive ./dricore-gallium.patch when it gets ported (from Ubuntu),
50+ # as it saved ~35 MB in $drivers; watch https://launchpad.net/ubuntu/+source/mesa/+changelog
5451 ] ++ optional stdenv.isLinux
5552 (substituteAll {
5653 src = ./dlopen-absolute-paths.diff;
@@ -64,59 +61,61 @@ stdenv.mkDerivation {
6461
6562 outputs = [ "dev" "out" "drivers" "osmesa" ];
6663
67− # TODO: Figure out how to enable opencl without having a runtime dependency on clang
6864 configureFlags = [
6965 "--sysconfdir=/etc"
7066 "--localstatedir=/var"
7167 "--with-dri-driverdir=$(drivers)/lib/dri"
7268 "--with-dri-searchpath=${driverLink}/lib/dri"
73− "--with-egl-platforms=x11,wayland,drm"
74− (optionalString (stdenv.system != "armv7l-linux")
75− "--with-gallium-drivers=svga,i915,ilo,r300,r600,radeonsi,nouveau,freedreno,swrast")
76− (optionalString (stdenv.system != "armv7l-linux")
77− "--with-dri-drivers=i915,i965,nouveau,radeon,r200,swrast")
78−
79− (enableFeature enableTextureFloats "texture-float")
80− (enableFeature grsecEnabled "glx-rts")
81− (enableFeature stdenv.isLinux "dri3")
82− (enableFeature stdenv.isLinux "nine") # Direct3D in Wine
83− "--enable-dri"
84− "--enable-driglx-direct"
69+
8570 "--enable-gles1"
8671 "--enable-gles2"
72+ "--enable-dri"
73+ ] ++ optional stdenv.isLinux "--enable-dri3"
74+ ++ [
8775 "--enable-glx"
88− "--enable-glx-tls"
8976 "--enable-gallium-osmesa" # used by wine
90− "--enable-gallium-llvm"
9177 "--enable-egl"
9278 "--enable-xa" # used in vmware driver
9379 "--enable-gbm"
80+ ] ++ optional stdenv.isLinux "--enable-nine" # Direct3D in Wine
81+ ++ [
9482 "--enable-xvmc"
9583 "--enable-vdpau"
84+ #"--enable-omx"
85+ #"--enable-va"
86+
87+ # TODO: Figure out how to enable opencl without having a runtime dependency on clang
88+ "--disable-opencl"
89+
90+ (if "armv7l-linux" == stdenv.system
91+ then null
92+ else "--with-gallium-drivers=svga,i915,ilo,r300,r600,radeonsi,nouveau,freedreno,swrast")
9693 "--enable-shared-glapi"
9794 "--enable-sysfs"
95+ "--enable-driglx-direct" # seems enabled anyway
96+ "--enable-glx-tls"
97+ (if "armv7l-linux" == stdenv.system
98+ then "--with-dri-drivers="
99+ else "--with-dri-drivers=i915,i965,nouveau,radeon,r200,swrast")
100+ "--with-egl-platforms=x11,wayland,drm"
101+
102+ "--enable-gallium-llvm"
98103 "--enable-llvm-shared-libs"
99− "--enable-omx"
100− "--enable-va"
101− "--disable-opencl"
102− ];
104+ ] ++ optional enableTextureFloats "--enable-texture-float"
105+ ++ optional grsecEnabled "--enable-glx-rts"; # slight performance degradation, enable only for grsec
103106
104107 nativeBuildInputs = [ pkgconfig file ];
105108
106− propagatedBuildInputs = with xorg;
107− [ libXdamage libXxf86vm ]
109+ propagatedBuildInputs = with xorg; [ libXdamage libXxf86vm ]
108110 ++ optional stdenv.isLinux libdrm;
109111
110112 buildInputs = with xorg; [
111113 autoreconfHook intltool expat llvmPackages.llvm
112114 glproto dri2proto dri3proto presentproto
113115 libX11 libXext libxcb libXt libXfixes libxshmfence
114− libffi wayland libvdpau libelf libXvMC
115− libomxil-bellagio libva libpthreadstubs
116− (python.withPackages (ps: [ ps.Mako ]))
116+ libffi wayland libvdpau libelf libXvMC /* libomxil-bellagio libva */
117117 ] ++ optional stdenv.isLinux libudev;
118118
119−
120119 enableParallelBuilding = true;
121120 doCheck = false;
122121
@@ -125,42 +124,42 @@ stdenv.mkDerivation {
125124 "localstatedir=\${TMPDIR}"
126125 ];
127126
128− # TODO: probably not all .la files are completely fixed, but it shouldn't matter;
129− postInstall = ''
130− # move gallium-related stuff to $drivers, so $out doesn't depend on LLVM
131− mv -t "$drivers/lib/" \
132− $out/lib/libXvMC* \
133− $out/lib/d3d \
134− $out/lib/vdpau \
135− $out/lib/bellagio \
136− $out/lib/libxatracker* \
137−
138− mv $out/lib/dri/* $drivers/lib/dri
127+ # move gallium-related stuff to $drivers, so $out doesn't depend on LLVM;
128+ # also move libOSMesa to $osmesa, as it's relatively big
129+ # ToDo: probably not all .la files are completely fixed, but it shouldn't matter
130+ postInstall = with stdenv.lib; ''
131+ mv -t "$drivers/lib/" \
132+ $out/lib/libXvMC* \
133+ $out/lib/d3d \
134+ $out/lib/vdpau \
135+ $out/lib/libxatracker*
139136
140− # move libOSMesa to $osmesa, as it's relatively big
141137 mkdir -p {$osmesa,$drivers}/lib/
142− mv -t $osmesa/lib/ $out/lib/libOSMesa*
138+ mv -t $osmesa/lib/ \
139+ $out/lib/libOSMesa*
143140
144− # now fix references in .la files
145− sed "/^libdir=/s,$out,$osmesa," -i $osmesa/lib/libOSMesa*.la
141+ '' + /* now fix references in .la files */ ''
142+ sed "/^libdir=/s,$out,$osmesa," -i \
143+ $osmesa/lib/libOSMesa*.la
146144
147− # set the default search path for DRI drivers; used e.g. by X server
145+ '' + /* set the default search path for DRI drivers; used e.g. by X server */ ''
148146 substituteInPlace "$dev/lib/pkgconfig/dri.pc" --replace '$(drivers)' "${driverLink}"
149147 '';
148+ #ToDo: @vcunat isn't sure if drirc will be found when in $out/etc/, but it doesn't seem important ATM */
150149
151− # TODO:
152− # @vcunat isn't sure if drirc will be found when in $out/etc/;
153− # check $out doesn't depend on llvm: builder failures are ignored
154− # for some reason grep -qv '${llvmPackages.llvm}' -R "$out";
155− postFixup = ''
150+ postFixup =
156151 # add RPATH so the drivers can find the moved libgallium and libdricore9
157152 # moved here to avoid problems with stripping patchelfed files
153+ ''
158154 for lib in $drivers/lib/*.so* $drivers/lib/*/*.so*; do
159155 if [[ ! -L "$lib" ]]; then
160156 patchelf --set-rpath "$(patchelf --print-rpath $lib):$drivers/lib" "$lib"
161157 fi
162158 done
163159 '';
160+ # ToDo + /* check $out doesn't depend on llvm */ ''
161+ # builder failures are ignored for some reason
162+ # grep -qv '${llvmPackages.llvm}' -R "$out"
164163
165164 passthru = { inherit libdrm version driverLink; };
166165