Files
nixpkgs/pkgs/by-name/in/intel-oneapi-toolkit/package.nix
2026-06-25 17:00:00 +02:00

336 lines
9.7 KiB
Nix

{
lib,
stdenv,
callPackage,
fetchurl,
ncurses5,
bc,
bubblewrap,
autoPatchelfHook,
python3,
libgcc,
glibc,
writableTmpDirAsHomeHook,
writeShellApplication,
curl,
jq,
common-updater-scripts,
zlib,
rdma-core,
libpsm2,
ucx,
numactl,
level-zero,
libdrm,
elfutils,
libxrandr,
libxfixes,
libxext,
libxdamage,
libxcomposite,
libx11,
libxcb,
glib,
nss,
nspr,
dbus,
at-spi2-atk,
cups,
gtk3,
pango,
cairo,
libgbm,
expat,
libxkbcommon,
eudev,
alsa-lib,
bzip2,
gdbm,
libxcrypt-legacy,
libuuid,
sqlite,
libffi,
bash,
# The list of components to install;
# Either [ "all" ], [ "default" ], or a custom list of components.
# If you want to install all default components plus an extra one, pass [ "default" <your extra components here> ]
# Note that changing this will also change the `buildInputs` of the derivation.
components ? [ "all" ],
}:
let
shortName = name: builtins.elemAt (lib.splitString "." name) 3;
mkUpdateScript =
{
pname,
downloadPage,
file,
}:
lib.getExe (writeShellApplication {
name = "update-intel-oneapi";
runtimeInputs = [
curl
jq
common-updater-scripts
];
text = ''
download_page=${lib.escapeShellArg downloadPage}
pname=${lib.escapeShellArg pname}
nixpkgs="$(git rev-parse --show-toplevel)"
file="$nixpkgs/pkgs/by-name/in/intel-oneapi-toolkit/${lib.escapeShellArg file}"
echo 'Figuring out the download URL' >&2
# NOTE: Do NOT scrape the `wget ...` command that Intel renders on the
# product page. Intel updates that snippet by hand and occasionally forgets
# to (e.g. 2026.0.1 shipped while the snippet still pointed at 2026.0.0.198).
# Instead we drive the same API the page's own JavaScript uses to populate the version/checksum panel:
#
# 1. The product page references a per-product config JSON under
# .../uswd-json-files/oneapi-toolkit/toolkit-<ver>.json
# 2. That config carries Intel's internal IRC component UUID for the
# toolkit (irc.unbundledComponents."oneapi-toolkit"[0]).
# 3. /libs/apps/intel/idz/productsinfo?downloadId=<uuid> returns the live
# file list, each entry with the real url + checksums + version.
# We then pick the Linux offline installer (.sh) from that list.
# 1. Discover the config JSON the page links to
config_path="$(curl -fsS "$download_page" \
| grep -oE '/content/dam/[^"]*uswd-json-files/oneapi-toolkit/[^"]+[.]json' \
| head -n1)"
if [[ -z "$config_path" ]]; then
echo "Could not find the toolkit config JSON on $download_page" >&2
exit 1
fi
# 2. Extract the IRC component UUID
component_id="$(curl -fsS "https://www.intel.com$config_path" \
| jq -r '.irc.unbundledComponents."oneapi-toolkit"[0]')"
if [[ -z "$component_id" || "$component_id" == "null" ]]; then
echo "Could not extract the IRC component UUID from $config_path" >&2
exit 1
fi
# 3. Resolve the component to its live file list and pick the Linux
# offline installer
# NOTE: Intel's field name really is misspelled "downlaodFileName"
file_entry="$(curl -fsS "https://www.intel.com/libs/apps/intel/idz/productsinfo?downloadId=$component_id" \
| jq -r '[.. | objects | select(.downlaodFileName? != null)
| select(.operatingSystem == "linux")
| select(.downlaodFileName | test("_offline[.]sh$"))][0]')"
url="$(echo "$file_entry" | jq -r '.url')"
filename="$(echo "$file_entry" | jq -r '.downlaodFileName')"
if [[ -z "$url" || "$url" == "null" ]]; then
echo "Could not find a Linux offline (.sh) installer for component $component_id" >&2
exit 1
fi
regex="$pname-([0-9]+)[.]([0-9]+)[.]([0-9]+)[.]([0-9]+)_offline[.]sh"
if [[ "$filename" =~ $regex ]]; then
versionYear="''${BASH_REMATCH[1]}"
versionMajor="''${BASH_REMATCH[2]}"
versionMinor="''${BASH_REMATCH[3]}"
versionRel="''${BASH_REMATCH[4]}"
else
echo "'$filename' does not match the expected format $regex" >&2
exit 1
fi
if grep -qF "url = \"$url\"" "$file"; then
echo "The URL is the same ($url), skipping update" >&2
exit 0
fi
echo "The new download URL is $url, prefetching it to store" >&2
hash="$(nix hash convert --hash-algo sha256 "$(nix-prefetch-url --quiet "$url")")"
sed -i "s|versionYear = \".*\";|versionYear = \"$versionYear\";|" "$file"
sed -i "s|versionMajor = \".*\";|versionMajor = \"$versionMajor\";|" "$file"
sed -i "s|versionMinor = \".*\";|versionMinor = \"$versionMinor\";|" "$file"
sed -i "s|versionRel = \".*\";|versionRel = \"$versionRel\";|" "$file"
sed -i "s|url = \".*\";|url = \"$url\";|" "$file"
sed -i "s|hash = \".*\";|hash = \"$hash\";|" "$file"
'';
});
# Figured out by looking at autoPatchelfHook failure output
depsByComponent = rec {
dpcpp-cpp-compiler = [
zlib
level-zero
];
dpcpp_dbg = [
level-zero
zlib
];
dpcpp-ct = [ zlib ];
mpi = [
zlib
rdma-core
libpsm2
ucx
libuuid
numactl
level-zero
libffi
];
pti = [ level-zero ];
vtune = [
libdrm
elfutils
zlib
libx11
libxext
libxcb
libxcomposite
libxdamage
libxfixes
libxrandr
glib
nss
dbus
at-spi2-atk
cups
gtk3
pango
cairo
libgbm
expat
libxkbcommon
eudev
alsa-lib
at-spi2-atk
ncurses5
bzip2
libuuid
gdbm
libxcrypt-legacy
sqlite
nspr
];
ifort-compiler = [ ];
tbb = [ ];
mkl = mpi ++ pti;
};
in
stdenv.mkDerivation (finalAttrs: {
pname = "intel-oneapi-toolkit";
versionYear = "2026";
versionMajor = "0";
versionMinor = "1";
versionRel = "27";
version = "${finalAttrs.versionYear}.${finalAttrs.versionMajor}.${finalAttrs.versionMinor}.${finalAttrs.versionRel}";
strictDeps = true;
__structuredAttrs = true;
src = fetchurl {
url = "https://registrationcenter-download.intel.com/akdlm/IRC_NAS/c9c3d3e3-ddb4-490e-bb41-6e9041ba32a7/intel-oneapi-toolkit-2026.0.1.27_offline.sh";
hash = "sha256-MCMdAN4BCIkuptUOeFCRtAy4eQuwBryl5PXmRzWjPPo=";
};
nativeBuildInputs = [
ncurses5
bc
bubblewrap
autoPatchelfHook
writableTmpDirAsHomeHook
];
buildInputs = [
python3
# Required for patchShebangs to discover the correct interpreter
bash
]
++ lib.concatMap (
comp:
if comp == "all" || comp == "default" then
lib.concatLists (builtins.attrValues depsByComponent)
else
depsByComponent.${shortName comp} or [ ]
) components;
dontUnpack = true;
# See https://software.intel.com/content/www/us/en/develop/documentation/installation-guide-for-intel-oneapi-toolkits-linux/top/installation/install-with-command-line.html
installPhase = ''
runHook preInstall
mkdir -p "$out"
export LD_LIBRARY_PATH="${lib.makeLibraryPath [ libgcc.lib ]}"
# The installer is an insane four-stage rube goldberg machine:
# 1. Our $src (bash script) unpacks install.sh (bash script)
# 2. install.sh unpacks bootstrapper (dylinked binary with hardcoded interpreter in /lib)
# 3. bootstrapper unpacks installer (dylinked binary with hardcoded interpreter and libraries in /lib)
# 4. installer installs the actual components we need
#
# While stage 1 allows to "only extract", other stages always try running the next executable down, and remove stuff if they fail.
# I'm afraid this is the cleanest solution for now.
mkdir -p fhs-root/{lib,lib64}
ln -s "${glibc}/lib/"* fhs-root/lib/
ln -s "${glibc}/lib/"* fhs-root/lib64/
bwrap \
--bind fhs-root / \
--bind /nix /nix \
--ro-bind /bin /bin \
--dev /dev \
--proc /proc \
bash "$src" \
-a \
--silent \
--eula accept \
--install-dir "$out" \
--components ${lib.concatStringsSep ":" components}
rm -rf "$out"/logs
rm -rf "$out"/.toolkit_linking_tool
ln -s "$out/$versionYear.$versionMajor"/{lib,etc,bin,share,opt,include} "$out"
runHook postInstall
'';
autoPatchelfIgnoreMissingDeps = [
# Needs to be dynamically loaded as it depends on the hardware
"libcuda.so.1"
# All too old, not in nixpkgs anymore
"libffi.so.6"
"libgdbm.so.4"
"libreadline.so.6"
# Bundled only as unversioned .so in GTPin; the .so.14 soname isn't present
"libopencl-clang.so.14"
# 2026 ships libsycl.so.9; some vtune binaries still reference the old .so.8
"libsycl.so.8"
# GTPin internal, not present in the package
"liboutputgenerator.so"
];
passthru.updateScript = mkUpdateScript {
inherit (finalAttrs) pname;
file = "package.nix";
downloadPage = "https://www.intel.com/content/www/us/en/developer/tools/oneapi/oneapi-toolkit-download.html";
};
passthru.stdenv = callPackage ./stdenv.nix { kit = finalAttrs.finalPackage; };
passthru.tests = callPackage ./tests.nix { kit = finalAttrs.finalPackage; };
meta = {
description = "Intel oneAPI Toolkit";
homepage = "https://www.intel.com/content/www/us/en/developer/tools/oneapi/oneapi-toolkit.html";
license = with lib.licenses; [
intel-eula
issl
asl20
];
maintainers = with lib.maintainers; [
balsoft
kilyanni
];
platforms = [ "x86_64-linux" ];
};
})