lol
1{ stdenv, lib, fetchurl, kernel ? null, which
2, xorg, makeWrapper, glibc, patchelf, unzip
3, fontconfig, freetype, libGLU_combined # for fgl_glxgears
4, # Whether to build the libraries only (i.e. not the kernel module or
5 # driver utils). Used to support 32-bit binaries on 64-bit
6 # Linux.
7 libsOnly ? false
8}:
9
10assert (!libsOnly) -> kernel != null;
11
12with stdenv.lib;
13
14# This derivation requires a maximum of gcc49, Linux kernel 4.1 and xorg.xserver 1.17
15# and will not build or run using versions newer
16
17# If you want to use a different Xorg version probably
18# DIR_DEPENDING_ON_XORG_VERSION in builder.sh has to be adopted (?)
19# make sure libglx.so of ati is used. xorg.xorgserver does provide it as well
20# which is a problem because it doesn't contain the xorgserver patch supporting
21# the XORG_DRI_DRIVER_PATH env var.
22# See http://thread.gmane.org/gmane.linux.distributions.nixos/4145 for a
23# workaround (TODO)
24
25# The gentoo ebuild contains much more "magic" and is usually a great resource to
26# find patches XD
27
28# http://wiki.cchtml.com/index.php/Main_Page
29
30# /usr/lib/dri/fglrx_dri.so must point to /run/opengl-driver/lib/fglrx_dri.so
31# This is done in the builder script.
32
33stdenv.mkDerivation rec {
34
35 version = "15.12";
36 pname = "ati-drivers";
37 build = "15.302";
38
39 linuxonly =
40 if stdenv.hostPlatform.system == "i686-linux" then
41 true
42 else if stdenv.hostPlatform.system == "x86_64-linux" then
43 true
44 else throw "ati-drivers are Linux only. Sorry. The build was stopped.";
45
46 name = pname + "-" + version + (optionalString (!libsOnly) "-${kernelDir.version}");
47
48 builder = ./builder.sh;
49 gcc = stdenv.cc.cc;
50 libXinerama = xorg.libXinerama;
51 libXrandr = xorg.libXrandr;
52 libXrender = xorg.libXrender;
53 libXxf86vm = xorg.libXxf86vm;
54 xf86vidmodeproto = xorg.xf86vidmodeproto;
55 libSM = xorg.libSM;
56 libICE = xorg.libICE;
57 libfreetype = freetype;
58 libfontconfig = fontconfig;
59 libStdCxx = stdenv.cc.cc.lib;
60
61 src = fetchurl {
62 url =
63 "https://www2.ati.com/drivers/linux/radeon-crimson-15.12-15.302-151217a-297685e.zip";
64 sha256 = "0n0ynqmjkjp5dl5q07as7ps3rlyyn63hq4mlwgd7c7v82ky2skvh";
65 curlOpts = "--referer http://support.amd.com/en-us/download/desktop?os=Linux+x86_64";
66 };
67
68 hardeningDisable = [ "pic" "format" ];
69
70 patchPhaseSamples = "patch -p2 < ${./patches/patch-samples.patch}";
71 patches = [
72 ./patches/15.12-xstate-fp.patch
73 ./patches/15.9-kcl_str.patch
74 ./patches/15.9-mtrr.patch
75 ./patches/15.9-preempt.patch
76 ./patches/15.9-sep_printf.patch ]
77 ++ optionals ( kernel != null &&
78 (lib.versionAtLeast kernel.version "4.6") )
79 [ ./patches/kernel-4.6-get_user_pages.patch
80 ./patches/kernel-4.6-page_cache_release-put_page.patch ]
81 ++ optionals ( kernel != null &&
82 (lib.versionAtLeast kernel.version "4.7") )
83 [ ./patches/4.7-arch-cpu_has_pge-v2.patch ]
84 ++ optionals ( kernel != null &&
85 (lib.versionAtLeast kernel.version "4.9") )
86 [ ./patches/4.9-get_user_pages.patch ];
87
88 buildInputs =
89 [ xorg.libXrender xorg.libXext xorg.libX11 xorg.libXinerama xorg.libSM
90 xorg.libXrandr xorg.libXxf86vm xorg.xf86vidmodeproto xorg.imake xorg.libICE
91 patchelf
92 unzip
93 libGLU_combined
94 fontconfig
95 freetype
96 makeWrapper
97 which
98 ];
99
100 inherit libsOnly;
101
102 kernelDir = if libsOnly then null else kernel.dev;
103
104 # glibc only used for setting the binaries interpreter
105 glibcDir = glibc.out;
106
107 # outputs TODO: probably many fixes are needed;
108 LD_LIBRARY_PATH = makeLibraryPath
109 [ xorg.libXrender xorg.libXext xorg.libX11 xorg.libXinerama xorg.libSM
110 xorg.libXrandr xorg.libXxf86vm xorg.xf86vidmodeproto xorg.imake xorg.libICE
111 libGLU_combined
112 fontconfig
113 freetype
114 stdenv.cc.cc
115 ];
116
117 # without this some applications like blender don't start, but they start
118 # with nvidia. This causes them to be symlinked to $out/lib so that they
119 # appear in /run/opengl-driver/lib which get's added to LD_LIBRARY_PATH
120
121 extraDRIlibs = [ xorg.libXrandr.out xorg.libXrender.out xorg.libXext.out
122 xorg.libX11.out xorg.libXinerama.out xorg.libSM.out
123 xorg.libICE.out ];
124
125 inherit libGLU_combined; # only required to build the examples
126
127 enableParallelBuilding = true;
128
129 meta = with stdenv.lib; {
130 description = "ATI Catalyst display drivers";
131 homepage = http://support.amd.com/us/gpudownload/Pages/index.aspx;
132 license = licenses.unfree;
133 maintainers = with maintainers; [ marcweber offline jgeerds jerith666 ];
134 platforms = platforms.linux;
135 hydraPlatforms = [];
136 # Copied from the nvidia default.nix to prevent a store collision.
137 priority = 4;
138 };
139
140}