1{ lib, stdenv, fetchzip, rpmextract, ncurses5, numactl, zlib }:
2
3stdenv.mkDerivation rec {
4 pname = "intel-ocl";
5 version = "5.0-63503";
6
7 src = fetchzip {
8 # https://github.com/NixOS/nixpkgs/issues/166886
9 urls = [
10 "https://registrationcenter-download.intel.com/akdlm/irc_nas/11396/SRB5.0_linux64.zip"
11 "http://registrationcenter-download.intel.com/akdlm/irc_nas/11396/SRB5.0_linux64.zip"
12 "https://web.archive.org/web/20190526190814/http://registrationcenter-download.intel.com/akdlm/irc_nas/11396/SRB5.0_linux64.zip"
13 ];
14 sha256 = "0qbp63l74s0i80ysh9ya8x7r79xkddbbz4378nms9i7a0kprg9p2";
15 stripRoot = false;
16 };
17
18 buildInputs = [ rpmextract ];
19
20 sourceRoot = ".";
21
22 libPath = lib.makeLibraryPath [
23 stdenv.cc.cc.lib
24 ncurses5
25 numactl
26 zlib
27 ];
28
29 postUnpack = ''
30 # Extract the RPMs contained within the source ZIP.
31 rpmextract source/intel-opencl-r${version}.x86_64.rpm
32 rpmextract source/intel-opencl-cpu-r${version}.x86_64.rpm
33 '';
34
35 patchPhase = ''
36 runHook prePatch
37
38 # Remove libOpenCL.so, since we use ocl-icd's libOpenCL.so instead and this would cause a clash.
39 rm opt/intel/opencl/libOpenCL.so*
40
41 # Patch shared libraries.
42 for lib in opt/intel/opencl/*.so; do
43 patchelf --set-rpath "${libPath}:$out/lib/intel-ocl" $lib || true
44 done
45
46 runHook postPatch
47 '';
48
49 buildPhase = ''
50 runHook preBuild
51
52 # Create ICD file, which just contains the path of the corresponding shared library.
53 echo "$out/lib/intel-ocl/libintelocl.so" > intel.icd
54
55 runHook postBuild
56 '';
57
58 installPhase = ''
59 runHook preInstall
60
61 install -D -m 0755 opt/intel/opencl/*.so* -t $out/lib/intel-ocl
62 install -D -m 0644 opt/intel/opencl/*.{o,rtl,bin} -t $out/lib/intel-ocl
63 install -D -m 0644 opt/intel/opencl/{LICENSE,NOTICES} -t $out/share/doc/intel-ocl
64 install -D -m 0644 intel.icd -t $out/etc/OpenCL/vendors
65
66 runHook postInstall
67 '';
68
69 dontStrip = true;
70
71 meta = {
72 description = "Official OpenCL runtime for Intel CPUs";
73 homepage = "https://software.intel.com/en-us/articles/opencl-drivers";
74 license = lib.licenses.unfree;
75 platforms = [ "x86_64-linux" ];
76 maintainers = [ lib.maintainers.kierdavis ];
77 };
78}