forked from rarias/jungle
157 lines
3.5 KiB
Nix
157 lines
3.5 KiB
Nix
{
|
|
stdenv,
|
|
stdenvNoCC,
|
|
lib,
|
|
symlinkJoin,
|
|
autoPatchelfHook,
|
|
wrapIntel,
|
|
overrideCC,
|
|
hwloc,
|
|
libelf,
|
|
libffi_3_3,
|
|
libpsm2,
|
|
libuuid,
|
|
libxml2,
|
|
numactl,
|
|
ocl-icd,
|
|
openssl,
|
|
python3,
|
|
rdma-core,
|
|
ucx,
|
|
zlib,
|
|
writeTextFile,
|
|
}:
|
|
|
|
lib.makeOverridable (
|
|
{
|
|
unpatched,
|
|
components ? { },
|
|
extraPackages ? components.extraPackages or [ ],
|
|
}:
|
|
|
|
let
|
|
inherit (builtins)
|
|
attrValues
|
|
filter
|
|
mapAttrs
|
|
removeAttrs
|
|
;
|
|
|
|
inherit (components) llvmMajorVersion;
|
|
|
|
__components = removeAttrs components [
|
|
"extraPackages"
|
|
"llvmMajorVersion"
|
|
];
|
|
_components = __components;
|
|
# _components = lib.traceSeqN 2 {
|
|
# inherit unpatched __components;
|
|
# deps = builtins.map (x: "${x.pname}-${x.version}") unpatched.deps;
|
|
# } __components;
|
|
|
|
in
|
|
stdenvNoCC.mkDerivation (finalAttrs: {
|
|
pname = lib.removeSuffix "-extracted" unpatched.pname;
|
|
inherit (unpatched) version;
|
|
src = unpatched;
|
|
|
|
phases = [
|
|
"installPhase"
|
|
"fixupPhase"
|
|
];
|
|
buildInputs = [
|
|
libffi_3_3
|
|
libelf
|
|
libxml2
|
|
hwloc
|
|
numactl
|
|
libuuid
|
|
libpsm2
|
|
zlib
|
|
ocl-icd
|
|
rdma-core
|
|
ucx
|
|
openssl
|
|
python3
|
|
stdenv.cc.cc.lib
|
|
]
|
|
++ extraPackages;
|
|
|
|
autoPatchelfIgnoreMissingDeps = [
|
|
"libhwloc.so.5"
|
|
"libcuda.so.1"
|
|
"libze_loader.so.1"
|
|
];
|
|
|
|
# There are broken symlinks that go outside packages, ignore them
|
|
dontCheckForBrokenSymlinks = true;
|
|
|
|
nativeBuildInputs = [ autoPatchelfHook ];
|
|
installPhase = ''
|
|
cp -r $src/opt/intel/oneapi/ $out
|
|
'';
|
|
|
|
passthru =
|
|
let
|
|
pkgs = mapAttrs (
|
|
folder: version:
|
|
let
|
|
original = "${finalAttrs.finalPackage}/${folder}/${version}";
|
|
|
|
etc-vendors = writeTextFile {
|
|
name = "intel-ocl-icd";
|
|
text = "${original}/lib/libintelocl.so";
|
|
destination = "/etc/OpenCL/vendors/intel.icd";
|
|
};
|
|
in
|
|
symlinkJoin {
|
|
pname = "intel-${folder}";
|
|
inherit version;
|
|
paths = [ original ] ++ lib.optionals (folder == "compiler") [ etc-vendors ];
|
|
passthru = { inherit original llvmMajorVersion; };
|
|
}
|
|
) _components;
|
|
in
|
|
pkgs
|
|
// {
|
|
inherit unpatched;
|
|
pkgs = lib.recurseIntoAttrs pkgs;
|
|
components = _components;
|
|
|
|
# This contains all packages properly symlinked into toplevel directories
|
|
# in $out.
|
|
#
|
|
# NOTE: there are clashes with packages that have symlinks outside their
|
|
# scope (libtcm and env/vars.sh)
|
|
all = symlinkJoin {
|
|
pname = finalAttrs.finalPackage.pname + "-symlinked";
|
|
inherit (finalAttrs.finalPackage) version;
|
|
paths = filter lib.isDerivation (attrValues finalAttrs.finalPackage.pkgs);
|
|
};
|
|
|
|
stdenv = overrideCC stdenv finalAttrs.finalPackage.cc;
|
|
|
|
cc = wrapIntel {
|
|
cc = finalAttrs.finalPackage.pkgs.compiler;
|
|
extraBuildCommands = ''
|
|
wrap icx $wrapper $ccPath/icx
|
|
wrap icpx $wrapper $ccPath/icpx
|
|
wrap ifx $wrapper $ccPath/ifx
|
|
|
|
ln -s $out/bin/icpx $out/bin/c++
|
|
ln -s $out/bin/icx $out/bin/cc
|
|
|
|
sed -i 's/.*isCxx=0/isCxx=1/' $out/bin/icpx
|
|
'';
|
|
|
|
extraInstallCommands = ''
|
|
export named_cc="icx"
|
|
export named_cxx="icpx"
|
|
export named_fc="ifx"
|
|
'';
|
|
};
|
|
};
|
|
|
|
})
|
|
)
|