btrbk: add mainProgram (#356350)
[NixPkgs.git] / pkgs / by-name / in / intel-ocl / package.nix
blob1732fd76a735db04f878ec20b13b29a749b08a85
1 { lib, stdenv, fetchzip, rpmextract, ncurses5, numactl, zlib }:
3 stdenv.mkDerivation rec {
4   pname = "intel-ocl";
5   version = "5.0-63503";
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   };
18   buildInputs = [ rpmextract ];
20   sourceRoot = ".";
22   libPath = lib.makeLibraryPath [
23     stdenv.cc.cc
24     ncurses5
25     numactl
26     zlib
27   ];
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   '';
35   patchPhase = ''
36     runHook prePatch
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*
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
46     runHook postPatch
47   '';
49   buildPhase = ''
50     runHook preBuild
52     # Create ICD file, which just contains the path of the corresponding shared library.
53     echo "$out/lib/intel-ocl/libintelocl.so" > intel.icd
55     runHook postBuild
56   '';
58   installPhase = ''
59     runHook preInstall
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
66     runHook postInstall
67   '';
69   dontStrip = true;
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 = [ ];
77     sourceProvenance = [ lib.sourceTypes.binaryNativeCode ];
78   };