@@ -1,13 +1,12 @@
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
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
57, enableTextureFloats ? false # Texture floats are patented, see docs/patents.txt
68}:
79
8−if ! stdenv.lib.lists.elem stdenv.system stdenv.lib.platforms.mesaPlatforms then
9− throw "unsupported platform for Mesa"
10−else
1110
1211/** Packaging design:
1312 - The basic mesa ($out) contains headers and libraries (GLU is in mesa_glu now).
@@ -20,11 +19,15 @@ else
2019 - libOSMesa is in $osmesa (~4 MB)
2120*/
2221
23−with { inherit (stdenv.lib) optional optionalString; };
22+with stdenv.lib;
23+
24+if ! lists.elem stdenv.system platforms.mesaPlatforms then
25+ throw "unsupported platform for Mesa"
26+else
2427
2528let
26− version = "11.2.2";
27− # this is the default search path for DRI drivers
29+ version = "12.0.1";
30+ branch = head (splitString "." version);
2831 driverLink = "/run/opengl-driver" + optionalString stdenv.isi686 "-32";
2932in
3033
@@ -34,20 +37,20 @@ stdenv.mkDerivation {
3437 src = fetchurl {
3538 urls = [
3639 "ftp://ftp.freedesktop.org/pub/mesa/${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'')
40+ "ftp://ftp.freedesktop.org/pub/mesa/older-versions/${branch}.x/${version}/mesa-${version}.tar.xz"
3941 "https://launchpad.net/mesa/trunk/${version}/+download/mesa-${version}.tar.xz"
4042 ];
41− sha256 = "40e148812388ec7c6d7b6657d5a16e2e8dabba8b97ddfceea5197947647bdfb4";
43+ sha256 = "12b3i59xdn2in2hchrkgh4fwij8zhznibx976l3pdj3qkyvlzcms";
4244 };
4345
4446 prePatch = "patchShebangs .";
4547
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
4651 patches = [
4752 ./glx_ro_text_segm.patch # fix for grsecurity/PaX
4853 ./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
5154 ] ++ optional stdenv.isLinux
5255 (substituteAll {
5356 src = ./dlopen-absolute-paths.diff;
@@ -61,61 +64,59 @@ stdenv.mkDerivation {
6164
6265 outputs = [ "dev" "out" "drivers" "osmesa" ];
6366
67+ # TODO: Figure out how to enable opencl without having a runtime dependency on clang
6468 configureFlags = [
6569 "--sysconfdir=/etc"
6670 "--localstatedir=/var"
6771 "--with-dri-driverdir=$(drivers)/lib/dri"
6872 "--with-dri-searchpath=${driverLink}/lib/dri"
69−
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"
7085 "--enable-gles1"
7186 "--enable-gles2"
72− "--enable-dri"
73− ] ++ optional stdenv.isLinux "--enable-dri3"
74− ++ [
7587 "--enable-glx"
88+ "--enable-glx-tls"
7689 "--enable-gallium-osmesa" # used by wine
90+ "--enable-gallium-llvm"
7791 "--enable-egl"
7892 "--enable-xa" # used in vmware driver
7993 "--enable-gbm"
80− ] ++ optional stdenv.isLinux "--enable-nine" # Direct3D in Wine
81− ++ [
8294 "--enable-xvmc"
8395 "--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")
9396 "--enable-shared-glapi"
9497 "--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"
10398 "--enable-llvm-shared-libs"
104− ] ++ optional enableTextureFloats "--enable-texture-float"
105− ++ optional grsecEnabled "--enable-glx-rts"; # slight performance degradation, enable only for grsec
99+ "--enable-omx"
100+ "--enable-va"
101+ "--disable-opencl"
102+ ];
106103
107104 nativeBuildInputs = [ pkgconfig file ];
108105
109− propagatedBuildInputs = with xorg; [ libXdamage libXxf86vm ]
106+ propagatedBuildInputs = with xorg;
107+ [ libXdamage libXxf86vm ]
110108 ++ optional stdenv.isLinux libdrm;
111109
112110 buildInputs = with xorg; [
113111 autoreconfHook intltool expat llvmPackages.llvm
114112 glproto dri2proto dri3proto presentproto
115113 libX11 libXext libxcb libXt libXfixes libxshmfence
116− libffi wayland libvdpau libelf libXvMC /* libomxil-bellagio libva */
114+ libffi wayland libvdpau libelf libXvMC
115+ libomxil-bellagio libva libpthreadstubs
116+ (python.withPackages (ps: [ ps.Mako ]))
117117 ] ++ optional stdenv.isLinux libudev;
118118
119+
119120 enableParallelBuilding = true;
120121 doCheck = false;
121122
@@ -124,42 +125,42 @@ stdenv.mkDerivation {
124125 "localstatedir=\${TMPDIR}"
125126 ];
126127
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*
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
136139
140+ # move libOSMesa to $osmesa, as it's relatively big
137141 mkdir -p {$osmesa,$drivers}/lib/
138− mv -t $osmesa/lib/ \
139− $out/lib/libOSMesa*
142+ mv -t $osmesa/lib/ $out/lib/libOSMesa*
140143
141− '' + /* now fix references in .la files */ ''
142− sed "/^libdir=/s,$out,$osmesa," -i \
143− $osmesa/lib/libOSMesa*.la
144+ # now fix references in .la files
145+ sed "/^libdir=/s,$out,$osmesa," -i $osmesa/lib/libOSMesa*.la
144146
145− '' + /* set the default search path for DRI drivers; used e.g. by X server */ ''
147+ # set the default search path for DRI drivers; used e.g. by X server
146148 substituteInPlace "$dev/lib/pkgconfig/dri.pc" --replace '$(drivers)' "${driverLink}"
147149 '';
148− #ToDo: @vcunat isn't sure if drirc will be found when in $out/etc/, but it doesn't seem important ATM */
149150
150− postFixup =
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 = ''
151156 # add RPATH so the drivers can find the moved libgallium and libdricore9
152157 # moved here to avoid problems with stripping patchelfed files
153− ''
154158 for lib in $drivers/lib/*.so* $drivers/lib/*/*.so*; do
155159 if [[ ! -L "$lib" ]]; then
156160 patchelf --set-rpath "$(patchelf --print-rpath $lib):$drivers/lib" "$lib"
157161 fi
158162 done
159163 '';
160− # ToDo + /* check $out doesn't depend on llvm */ ''
161− # builder failures are ignored for some reason
162− # grep -qv '${llvmPackages.llvm}' -R "$out"
163164
164165 passthru = { inherit libdrm version driverLink; };
165166