976 lines
32 KiB
Nix
976 lines
32 KiB
Nix
final: prev:
|
|
let
|
|
winePkg = final.wineWow64Packages.full;
|
|
sandboxSccacheDir = "/var/cache/sccache/nix-builds/packages";
|
|
sharedSccacheConfig = final.writeText "sccache.conf" ''
|
|
[cache.disk]
|
|
dir = "${sandboxSccacheDir}"
|
|
size = "100G"
|
|
'';
|
|
versionBumpAttrs =
|
|
oldVersion: version: attrs:
|
|
if final.lib.versionOlder oldVersion version then attrs else { };
|
|
modify =
|
|
target: f:
|
|
if target ? overridePythonAttrs then
|
|
target.overridePythonAttrs f
|
|
else if target ? overrideAttrs then
|
|
target.overrideAttrs f
|
|
else if target ? overrideScope then
|
|
target.overrideScope f
|
|
else
|
|
throw "modify: target does not support overridePythonAttrs, overrideAttrs, or overrideScope";
|
|
mkRealCompilerBasePath =
|
|
{
|
|
name,
|
|
toolchain,
|
|
}:
|
|
final.runCommand name { } ''
|
|
resolve_orig_cc_root() {
|
|
local current_root="$1"
|
|
local next_root
|
|
|
|
while [ -r "$current_root/nix-support/orig-cc" ]; do
|
|
next_root="$(tr -d '\n' < "$current_root/nix-support/orig-cc")"
|
|
if [ -z "$next_root" ] || [ "$next_root" = "$current_root" ]; then
|
|
break
|
|
fi
|
|
current_root="$next_root"
|
|
done
|
|
|
|
printf '%s\n' "$current_root"
|
|
}
|
|
|
|
wrapped_clang="$(readlink -f ${toolchain}/bin/clang)"
|
|
wrapped_root="$(dirname "$(dirname "$wrapped_clang")")"
|
|
orig_cc_root="$(resolve_orig_cc_root "$wrapped_root")"
|
|
|
|
if [ -z "$orig_cc_root" ] || [ ! -d "$orig_cc_root/bin" ]; then
|
|
echo "mkRealCompilerBasePath: invalid orig-cc root: $orig_cc_root" >&2
|
|
exit 1
|
|
fi
|
|
if [ ! -x "$orig_cc_root/bin/clang" ] || [ ! -x "$orig_cc_root/bin/clang++" ]; then
|
|
echo "mkRealCompilerBasePath: clang or clang++ missing in $orig_cc_root/bin" >&2
|
|
exit 1
|
|
fi
|
|
|
|
mkdir -p "$out/bin"
|
|
|
|
for executable in ${toolchain}/bin/*; do
|
|
executable_name="$(basename "$executable")"
|
|
case "$executable_name" in
|
|
clang|clang++|cc|c++)
|
|
continue
|
|
;;
|
|
esac
|
|
ln -s "$executable" "$out/bin/$executable_name"
|
|
done
|
|
|
|
ln -s "$orig_cc_root/bin/clang" "$out/bin/clang"
|
|
ln -s "$orig_cc_root/bin/clang++" "$out/bin/clang++"
|
|
ln -s clang "$out/bin/cc"
|
|
ln -s clang++ "$out/bin/c++"
|
|
|
|
for path in ${toolchain}/*; do
|
|
path_name="$(basename "$path")"
|
|
if [ "$path_name" != bin ]; then
|
|
ln -s "$path" "$out/$path_name"
|
|
fi
|
|
done
|
|
'';
|
|
mkSccacheLauncher =
|
|
{
|
|
name,
|
|
sccacheDir ? null,
|
|
sccacheServerUds ? null,
|
|
sccacheCacheSize ? "100G",
|
|
noDaemon ? false,
|
|
passthroughWrappedCompiler ? false,
|
|
extraSetup ? "",
|
|
}:
|
|
let
|
|
sccacheConfig = final.writeText "${name}-config" ''
|
|
[cache.disk]
|
|
dir = "${if sccacheDir != null then sccacheDir else sandboxSccacheDir}"
|
|
size = "${sccacheCacheSize}"
|
|
'';
|
|
effectiveSccacheConfig =
|
|
if sccacheDir == null && sccacheCacheSize == "100G" then sharedSccacheConfig else sccacheConfig;
|
|
in
|
|
final.writeShellScriptBin name ''
|
|
is_cmake_derivation() {
|
|
case " ''${nativeBuildInputs:-} ''${propagatedNativeBuildInputs:-} " in
|
|
*"/cmake-"*) return 0 ;;
|
|
esac
|
|
|
|
[ -n "''${cmakeFlags:-}" ] || [ -n "''${cmakeDir:-}" ] || [ -n "''${cmakeBuildType:-}" ]
|
|
}
|
|
|
|
is_cmake_probe_invocation() {
|
|
local arg response_file
|
|
for arg in "$@"; do
|
|
case "$arg" in
|
|
*CMakeFiles/*CompilerId*|*CMakeFiles/CMakeTmp/*|*CMakeScratch/*)
|
|
return 0
|
|
;;
|
|
@*)
|
|
response_file="''${arg#@}"
|
|
if [ -f "$response_file" ] && grep -Eq 'CMakeFiles/.+CompilerId|CMakeFiles/CMakeTmp|CMakeScratch' "$response_file"; then
|
|
return 0
|
|
fi
|
|
;;
|
|
esac
|
|
done
|
|
|
|
return 1
|
|
}
|
|
|
|
export SCCACHE_CONF=${final.lib.escapeShellArg effectiveSccacheConfig}
|
|
mkdir -p ${final.lib.escapeShellArg sandboxSccacheDir}
|
|
unset SCCACHE_START_SERVER
|
|
${final.lib.optionalString noDaemon ''
|
|
export SCCACHE_NO_DAEMON=1
|
|
unset SCCACHE_SERVER_UDS
|
|
''}
|
|
${final.lib.optionalString (!noDaemon && sccacheServerUds != null) ''
|
|
export SCCACHE_SERVER_UDS=${final.lib.escapeShellArg sccacheServerUds}
|
|
''}
|
|
${extraSetup}
|
|
if [ "$#" -eq 0 ] || [ "''${1#-}" != "$1" ]; then
|
|
exec ${final.sccache}/bin/sccache "$@"
|
|
fi
|
|
|
|
compiler="$1"
|
|
shift
|
|
|
|
if [ "''${SCCACHE_WRAPPED_COMPILER_PASSTHROUGH:-}" = 1 ] || {
|
|
is_cmake_derivation && is_cmake_probe_invocation "$@"
|
|
}; then
|
|
exec "$compiler" "$@"
|
|
fi
|
|
|
|
${final.lib.optionalString passthroughWrappedCompiler ''
|
|
export SCCACHE_WRAPPED_COMPILER_PASSTHROUGH=1
|
|
''}
|
|
exec ${final.sccache}/bin/sccache "$compiler" "$@"
|
|
'';
|
|
buildSccacheLauncher = mkSccacheLauncher {
|
|
name = "build-sccache";
|
|
};
|
|
mkBuildSccacheAttrs = old: {
|
|
nativeBuildInputs = (old.nativeBuildInputs or [ ]) ++ [ buildSccacheLauncher ];
|
|
|
|
preConfigure = (old.preConfigure or "") + ''
|
|
|
|
mkdir -p ${final.lib.escapeShellArg sandboxSccacheDir}
|
|
export SCCACHE_SERVER_UDS="$TMPDIR/sccache/server.sock"
|
|
export SCCACHE_IDLE_TIMEOUT=0
|
|
unset SCCACHE_NO_DAEMON
|
|
mkdir -p "$(dirname "$SCCACHE_SERVER_UDS")"
|
|
if ! ${buildSccacheLauncher}/bin/build-sccache --show-stats >/dev/null 2>&1; then
|
|
rm -f "$SCCACHE_SERVER_UDS"
|
|
if ! ${buildSccacheLauncher}/bin/build-sccache --start-server >/tmp/sccache-start.log 2>&1; then
|
|
if ! grep -Fq "Address already in use" /tmp/sccache-start.log; then
|
|
cat /tmp/sccache-start.log >&2
|
|
exit 1
|
|
fi
|
|
fi
|
|
fi
|
|
'';
|
|
|
|
postBuild = (old.postBuild or "") + ''
|
|
|
|
${buildSccacheLauncher}/bin/build-sccache --show-stats --stats-format text || true
|
|
${buildSccacheLauncher}/bin/build-sccache --stop-server || true
|
|
'';
|
|
};
|
|
mkCmakeSccacheAttrs =
|
|
old:
|
|
let
|
|
sccacheLauncher = mkSccacheLauncher {
|
|
name = "cmake-sccache";
|
|
passthroughWrappedCompiler = true;
|
|
};
|
|
in
|
|
{
|
|
cmakeFlags = (old.cmakeFlags or [ ]) ++ [
|
|
"-DCMAKE_C_COMPILER_LAUNCHER=${sccacheLauncher}/bin/cmake-sccache"
|
|
"-DCMAKE_CXX_COMPILER_LAUNCHER=${sccacheLauncher}/bin/cmake-sccache"
|
|
];
|
|
|
|
nativeBuildInputs = (old.nativeBuildInputs or [ ]) ++ [ sccacheLauncher ];
|
|
|
|
preConfigure = (old.preConfigure or "") + ''
|
|
mkdir -p ${final.lib.escapeShellArg sandboxSccacheDir}
|
|
export SCCACHE_WRAPPED_COMPILER_PASSTHROUGH=1
|
|
export SCCACHE_SERVER_UDS="$TMPDIR/sccache/server.sock"
|
|
export SCCACHE_IDLE_TIMEOUT=0
|
|
unset SCCACHE_NO_DAEMON
|
|
mkdir -p "$(dirname "$SCCACHE_SERVER_UDS")"
|
|
if ! ${sccacheLauncher}/bin/cmake-sccache --show-stats >/dev/null 2>&1; then
|
|
rm -f "$SCCACHE_SERVER_UDS"
|
|
if ! ${sccacheLauncher}/bin/cmake-sccache --start-server >/tmp/sccache-start.log 2>&1; then
|
|
if ! grep -Fq "Address already in use" /tmp/sccache-start.log; then
|
|
cat /tmp/sccache-start.log >&2
|
|
exit 1
|
|
fi
|
|
fi
|
|
fi
|
|
'';
|
|
|
|
postConfigure = (old.postConfigure or "") + ''
|
|
unset SCCACHE_WRAPPED_COMPILER_PASSTHROUGH
|
|
'';
|
|
|
|
postBuild = (old.postBuild or "") + ''
|
|
|
|
${sccacheLauncher}/bin/cmake-sccache --show-stats --stats-format text || true
|
|
${sccacheLauncher}/bin/cmake-sccache --stop-server || true
|
|
'';
|
|
};
|
|
mkSccacheExtraConfig =
|
|
{
|
|
sccacheDir ? sandboxSccacheDir,
|
|
extraConfig ? "",
|
|
}:
|
|
''
|
|
mkdir -p ${final.lib.escapeShellArg sccacheDir}
|
|
export SCCACHE_CONF=${final.lib.escapeShellArg (
|
|
final.writeText "sccache-stdenv.conf" ''
|
|
[cache.disk]
|
|
dir = "${sccacheDir}"
|
|
size = "100G"
|
|
''
|
|
)}
|
|
export SCCACHE_NO_DAEMON=1
|
|
unset SCCACHE_SERVER_UDS
|
|
${extraConfig}
|
|
'';
|
|
mkWrappedCcForSccache =
|
|
{
|
|
cc,
|
|
extraConfig ? "",
|
|
}:
|
|
let
|
|
wrappedCompiler = final.sccache.links {
|
|
inherit extraConfig;
|
|
unwrappedCC = cc.cc;
|
|
};
|
|
overrideArgs = cc.override.__functionArgs or { };
|
|
in
|
|
if overrideArgs ? cc then
|
|
cc.override { cc = wrappedCompiler; }
|
|
else if overrideArgs ? llvm then
|
|
cc.override { llvm = wrappedCompiler; }
|
|
else
|
|
throw "mkWrappedCcForSccache: unsupported compiler wrapper override interface";
|
|
mkSccacheStdenv =
|
|
{
|
|
stdenv,
|
|
sccacheDir ? "/var/cache/sccache/nix-builds/packages",
|
|
extraConfig ? "",
|
|
}:
|
|
final.overrideCC stdenv (mkWrappedCcForSccache {
|
|
inherit (stdenv) cc;
|
|
extraConfig = mkSccacheExtraConfig {
|
|
inherit extraConfig sccacheDir;
|
|
};
|
|
});
|
|
in
|
|
{
|
|
sccache = modify prev.sccache (old: {
|
|
postPatch = (old.postPatch or "") + ''
|
|
substituteInPlace src/compiler/gcc.rs \
|
|
--replace-fail \
|
|
' take_arg!("-isystem", PathBuf, CanBeSeparated, PreprocessorArgumentPath),' \
|
|
' take_arg!("-isystem", PathBuf, CanBeSeparated, PreprocessorArgumentPath),
|
|
take_arg!("-cxx-isystem", PathBuf, CanBeSeparated, PreprocessorArgumentPath),'
|
|
'';
|
|
env = (old.env or { }) // {
|
|
RUSTC_WRAPPER = "${prev.sccache}/bin/sccache";
|
|
SCCACHE_CONF = sharedSccacheConfig;
|
|
};
|
|
preBuild = (old.preBuild or "") + ''
|
|
mkdir -p ${final.lib.escapeShellArg sandboxSccacheDir}
|
|
'';
|
|
passthru = (old.passthru or { }) // {
|
|
links =
|
|
{
|
|
unwrappedCC,
|
|
extraConfig ? "",
|
|
}:
|
|
let
|
|
sccacheLauncher = mkSccacheLauncher {
|
|
name = "wrapped-sccache";
|
|
noDaemon = true;
|
|
extraSetup = extraConfig;
|
|
};
|
|
in
|
|
final.stdenv.mkDerivation {
|
|
pname = "sccache-links";
|
|
inherit (old) version;
|
|
passthru = {
|
|
isClang = unwrappedCC.isClang or false;
|
|
isGNU = unwrappedCC.isGNU or false;
|
|
isSccache = true;
|
|
dev = unwrappedCC.dev or null;
|
|
lib = unwrappedCC.lib or (final.lib.getLib unwrappedCC);
|
|
}
|
|
// final.lib.optionalAttrs (unwrappedCC ? rsrc) {
|
|
inherit (unwrappedCC) rsrc;
|
|
};
|
|
dev = unwrappedCC.dev or null;
|
|
lib = unwrappedCC.lib or (final.lib.getLib unwrappedCC);
|
|
rsrc = unwrappedCC.rsrc or null;
|
|
nativeBuildInputs = [ final.makeWrapper ];
|
|
buildCommand =
|
|
let
|
|
targetPrefix =
|
|
if unwrappedCC.isClang or false then
|
|
""
|
|
else
|
|
(final.lib.optionalString (
|
|
unwrappedCC ? targetConfig && unwrappedCC.targetConfig != null && unwrappedCC.targetConfig != ""
|
|
) "${unwrappedCC.targetConfig}-");
|
|
in
|
|
''
|
|
mkdir -p $out/bin
|
|
mkdir -p $out/nix-support
|
|
|
|
wrap() {
|
|
local cname="${targetPrefix}$1"
|
|
if [ -x "${unwrappedCC}/bin/$cname" ]; then
|
|
makeWrapper ${sccacheLauncher}/bin/wrapped-sccache $out/bin/$cname \
|
|
--add-flags ${unwrappedCC}/bin/$cname
|
|
fi
|
|
}
|
|
|
|
wrap cc
|
|
wrap c++
|
|
wrap gcc
|
|
wrap g++
|
|
wrap clang
|
|
wrap clang++
|
|
|
|
for executable in $(ls ${unwrappedCC}/bin); do
|
|
if [ ! -x "$out/bin/$executable" ]; then
|
|
ln -s ${unwrappedCC}/bin/$executable $out/bin/$executable
|
|
fi
|
|
done
|
|
for file in $(ls ${unwrappedCC} | grep -vw bin); do
|
|
ln -s ${unwrappedCC}/$file $out/$file
|
|
done
|
|
|
|
printf '%s\n' "${unwrappedCC}" > $out/nix-support/orig-cc
|
|
'';
|
|
meta = final.lib.optionalAttrs (unwrappedCC.meta ? mainProgram) {
|
|
inherit (unwrappedCC.meta) mainProgram;
|
|
};
|
|
};
|
|
};
|
|
});
|
|
sccacheWrapper =
|
|
final.lib.makeOverridable
|
|
(
|
|
{
|
|
extraConfig ? "",
|
|
cc,
|
|
}:
|
|
mkWrappedCcForSccache {
|
|
inherit cc extraConfig;
|
|
}
|
|
)
|
|
{
|
|
extraConfig = "";
|
|
inherit (final.stdenv) cc;
|
|
};
|
|
sccacheStdenv = final.lib.lowPrio (
|
|
final.lib.makeOverridable
|
|
(
|
|
{
|
|
stdenv,
|
|
...
|
|
}@extraArgs:
|
|
final.overrideCC stdenv (
|
|
final.buildPackages.sccacheWrapper.override (
|
|
{
|
|
inherit (stdenv) cc;
|
|
}
|
|
// final.lib.optionalAttrs (builtins.hasAttr "extraConfig" extraArgs) {
|
|
extraConfig = extraArgs.extraConfig;
|
|
}
|
|
)
|
|
)
|
|
)
|
|
{
|
|
inherit (final) stdenv;
|
|
}
|
|
);
|
|
sccache-config = sharedSccacheConfig;
|
|
intel-sycl = modify prev.intel-sycl (
|
|
syFinal: syPrev:
|
|
let
|
|
sccacheWrappedDpcpp = final.sccache.links {
|
|
unwrappedCC = syFinal.dpcpp-compat;
|
|
extraConfig = mkSccacheExtraConfig { };
|
|
};
|
|
sccacheWrappedCompatStdenv = final.overrideCC syPrev.compatStdenv sccacheWrappedDpcpp;
|
|
# Inject sccache into stdenv without wrapping the compiler
|
|
# (avoids sccache-links-wrapper depending on intel-llvm-nightly directly)
|
|
sccacheStdenv = syPrev.stdenv.override (old: {
|
|
extraNativeBuildInputs = (old.extraNativeBuildInputs or [ ]) ++ [ final.sccache ];
|
|
preHook = (old.preHook or "") + ''
|
|
export SCCACHE_CONF=${final.lib.escapeShellArg sharedSccacheConfig}
|
|
${final.coreutils}/bin/mkdir -p ${final.lib.escapeShellArg sandboxSccacheDir}
|
|
export RUSTC_WRAPPER="${final.sccache}/bin/sccache"
|
|
'';
|
|
});
|
|
in
|
|
{
|
|
llvm = modify syPrev.llvm mkCmakeSccacheAttrs;
|
|
lld = modify syPrev.lld mkCmakeSccacheAttrs;
|
|
stdenv = sccacheStdenv;
|
|
compatStdenv = sccacheWrappedCompatStdenv;
|
|
}
|
|
);
|
|
# xdg-desktop-portal-cosmic = prev.xdg-desktop-portal-cosmic.overrideAttrs (old: {
|
|
# postPatch = (old.postPatch or "") + ''
|
|
# unitDir="$out/lib/systemd/user"
|
|
# ln -sfn org.freedesktop.impl.portal.desktop.cosmic.service \
|
|
# "$unitDir/xdg-desktop-portal-cosmic.service"
|
|
# '';
|
|
# });
|
|
# );
|
|
codex = modify prev.codex (
|
|
old:
|
|
let
|
|
version = "0.116.0";
|
|
in
|
|
(versionBumpAttrs old.version version (
|
|
let
|
|
src = prev.fetchFromGitHub {
|
|
owner = "openai";
|
|
repo = "codex";
|
|
tag = "rust-v${version}";
|
|
hash = "sha256-PTsKphg3gPlBUs5oMM34RhJJ4jxvD6hand5aVjXcuZ4=";
|
|
# hash = "";
|
|
};
|
|
in
|
|
{
|
|
inherit version src;
|
|
sourceRoot = "${src.name}/codex-rs";
|
|
|
|
cargoDeps = prev.rustPlatform.fetchCargoVendor {
|
|
inherit src;
|
|
sourceRoot = "${src.name}/codex-rs";
|
|
hash = "sha256-X5Yh8+3UrCZfzIplb4OzFfcfoklMu3FikU9vZ6CJbfc=";
|
|
# hash = prev.lib.fakeHash;
|
|
};
|
|
}
|
|
))
|
|
// {
|
|
buildInputs = (old.buildInputs or [ ]) ++ [ prev.libcap ];
|
|
|
|
preBuild = (old.preBuild or "") + ''
|
|
mkdir -p ${final.lib.escapeShellArg sandboxSccacheDir}
|
|
export CARGO_PROFILE_RELEASE_LTO=thin
|
|
export CARGO_PROFILE_RELEASE_CODEGEN_UNITS=8
|
|
'';
|
|
|
|
env = (old.env or { }) // {
|
|
RUSTC_WRAPPER = "${final.sccache}/bin/sccache";
|
|
SCCACHE_CONF = sharedSccacheConfig;
|
|
};
|
|
}
|
|
);
|
|
# electron_39 =
|
|
# let
|
|
# angleLib = final.lib.getLib final.angle;
|
|
# realElectronClangBasePath = mkRealCompilerBasePath {
|
|
# name = "electron-real-clang-base";
|
|
# toolchain = prev.electron_39.passthru.unwrapped.llvmCcAndBintools;
|
|
# };
|
|
# electronUnwrapped = modify prev.electron_39.passthru.unwrapped (
|
|
# old:
|
|
# let
|
|
# buildSccacheAttrs = mkBuildSccacheAttrs old;
|
|
# oldClangBasePath = "clang_base_path=\"${old.llvmCcAndBintools}\"";
|
|
# newClangBasePath = "clang_base_path=\"${realElectronClangBasePath}\"";
|
|
# baseGnFlags = builtins.replaceStrings [ oldClangBasePath ] [ newClangBasePath ] (old.gnFlags or "");
|
|
# electronGnFlags = "${baseGnFlags} cc_wrapper=\"${buildSccacheLauncher}/bin/build-sccache\"";
|
|
# in
|
|
# buildSccacheAttrs
|
|
# // {
|
|
# gnFlags = electronGnFlags;
|
|
# configurePhase = builtins.replaceStrings [ old.gnFlags or "" ] [ electronGnFlags ] (
|
|
# old.configurePhase or ""
|
|
# );
|
|
# patches = builtins.filter (
|
|
# patch: builtins.baseNameOf (toString patch) != "39-angle-patchdir.patch"
|
|
# ) (old.patches or [ ]);
|
|
# postPatch = ''
|
|
# substituteInPlace electron/patches/config.json \
|
|
# --replace-fail '"repo": "src/third_party/angle/src"' '"repo": "src/third_party/angle"'
|
|
# ''
|
|
# + (old.postPatch or "");
|
|
# postFixup = (old.postFixup or "") + ''
|
|
|
|
# for angleLibName in \
|
|
# libEGL.so \
|
|
# libEGL_vulkan_secondaries.so \
|
|
# libGLESv1_CM.so \
|
|
# libGLESv2.so \
|
|
# libGLESv2_vulkan_secondaries.so \
|
|
# libGLESv2_with_capture.so \
|
|
# libVkICD_mock_icd.so \
|
|
# libfeature_support.so
|
|
# do
|
|
# if [ -e "$libExecPath/$angleLibName" ] || [ -L "$libExecPath/$angleLibName" ]; then
|
|
# rm -f "$libExecPath/$angleLibName"
|
|
# fi
|
|
# ln -s ${angleLib}/lib/"$angleLibName" "$libExecPath/$angleLibName"
|
|
# done
|
|
# '';
|
|
# }
|
|
# );
|
|
# in
|
|
# prev.electron_39.override {
|
|
# electron-unwrapped = electronUnwrapped;
|
|
# };
|
|
electron_39 = prev.electron_39-bin;
|
|
oneapi-ccl =
|
|
modify
|
|
(prev.oneapi-ccl.override {
|
|
intel-sycl = final."intel-sycl";
|
|
})
|
|
(
|
|
old:
|
|
let
|
|
version = "2021.17.2";
|
|
intelSycl = final."intel-sycl".llvm;
|
|
intelSyclDev = final.lib.getDev intelSycl;
|
|
intelSyclLib = final.lib.getLib intelSycl;
|
|
levelZero = final.lib.getDev final.level-zero;
|
|
openclHeaders = final.opencl-headers;
|
|
cmakeSccacheAttrs = mkCmakeSccacheAttrs old;
|
|
in
|
|
(versionBumpAttrs old.version version {
|
|
inherit version;
|
|
|
|
src = prev.fetchFromGitHub {
|
|
owner = "uxlfoundation";
|
|
repo = "oneCCL";
|
|
rev = version;
|
|
hash = "sha256-dV1PadrcJSdwwpNxXAK1fo/B5p26Lvd36wqC+xM5KJM=";
|
|
};
|
|
})
|
|
// cmakeSccacheAttrs
|
|
// {
|
|
setOutputFlags = false;
|
|
|
|
postPatch = (old.postPatch or "") + ''
|
|
mkdir -p deps/level_zero
|
|
rm -rf deps/level_zero/include
|
|
ln -s ${levelZero}/include/level_zero deps/level_zero/include
|
|
|
|
sed -i '/^#if defined(SYCL_LANGUAGE_VERSION) && defined (__INTEL_LLVM_COMPILER)$/,/^#endif$/c\
|
|
#cmakedefine CCL_ENABLE_SYCL\
|
|
#cmakedefine CCL_ENABLE_ZE' include/oneapi/ccl/config.h.in
|
|
|
|
sed -i 's/^#define ICPX_VERSION 0$/#define ICPX_VERSION 140000/' src/common/utils/sycl_utils.hpp
|
|
|
|
sed -i '/^inline sycl::event get_last_event(const sycl::queue &q) {$/, /^inline sycl::event submit_wait_on_events(sycl::queue q, const std::vector<sycl::event> &deps) {$/c\
|
|
inline sycl::event get_last_event(const sycl::queue &q) {\
|
|
auto last_event_opt = q.ext_oneapi_get_last_event();\
|
|
if (last_event_opt.has_value()) {\
|
|
return last_event_opt.value();\
|
|
}\
|
|
return sycl::event{};\
|
|
}\
|
|
\
|
|
inline sycl::event submit_wait_on_events(sycl::queue q, const std::vector<sycl::event> \&deps) {' src/coll/algorithms/utils/sycl_coll_base.hpp
|
|
|
|
find src -type f \( -name '*.hpp' -o -name '*.cpp' \) \
|
|
-exec sed -i 's/reqd_sub_group_size(sg_size)/reqd_sub_group_size(32)/g' {} +
|
|
|
|
awk '
|
|
pending {
|
|
if ($0 ~ /^[[:space:]]*send_buf, new_send_count,/) {
|
|
sub(/send_buf, new_send_count,/, "q, send_buf, new_send_count,")
|
|
}
|
|
pending = 0
|
|
}
|
|
/^[[:space:]]*e = allgatherv_large\($/ {
|
|
pending = 1
|
|
}
|
|
{ print }
|
|
' src/coll/algorithms/allgatherv/sycl/allgatherv_sycl.cpp \
|
|
> src/coll/algorithms/allgatherv/sycl/allgatherv_sycl.cpp.tmp
|
|
mv src/coll/algorithms/allgatherv/sycl/allgatherv_sycl.cpp.tmp \
|
|
src/coll/algorithms/allgatherv/sycl/allgatherv_sycl.cpp
|
|
'';
|
|
|
|
cmakeFlags = (cmakeSccacheAttrs.cmakeFlags or [ ]) ++ [
|
|
"-DCMAKE_INSTALL_INCLUDEDIR=include"
|
|
"-DINTEL_SYCL_INCLUDE_DIRS=${intelSyclDev}/include"
|
|
"-DINTEL_SYCL_LIBRARIES=${intelSyclLib}/lib/libsycl.so"
|
|
];
|
|
|
|
buildInputs = (old.buildInputs or [ ]) ++ [ openclHeaders ];
|
|
|
|
meta = (old.meta or { }) // {
|
|
broken = false;
|
|
};
|
|
}
|
|
);
|
|
oneapi-math-sycl-blas = modify prev.oneapi-math-sycl-blas (old: mkCmakeSccacheAttrs old);
|
|
oneapi-math = modify prev.oneapi-math (old: mkCmakeSccacheAttrs old);
|
|
oneapi-dpl =
|
|
let
|
|
version = "2022.11.1";
|
|
in
|
|
modify prev.oneapi-dpl (
|
|
old:
|
|
(versionBumpAttrs old.version version {
|
|
inherit version;
|
|
|
|
src = prev.fetchFromGitHub {
|
|
owner = "uxlfoundation";
|
|
repo = "oneDPL";
|
|
rev = "oneDPL-${version}-release";
|
|
hash = "sha256-NfyV34mdKfCxlU+l6ETKWcC9MwvVEgwcBedtLe6WCV4=";
|
|
};
|
|
|
|
meta = (old.meta or { }) // {
|
|
changelog = "https://github.com/uxlfoundation/oneDPL/releases/tag/oneDPL-${version}-release";
|
|
};
|
|
})
|
|
// (mkCmakeSccacheAttrs old)
|
|
);
|
|
llama-cpp = modify prev.llama-cpp (
|
|
old:
|
|
let
|
|
version = "8124";
|
|
in
|
|
(versionBumpAttrs old.version version {
|
|
inherit version;
|
|
src = prev.fetchFromGitHub {
|
|
owner = "ggml-org";
|
|
repo = "llama.cpp";
|
|
tag = "b${version}";
|
|
hash = old.src.hash;
|
|
};
|
|
})
|
|
// (mkCmakeSccacheAttrs old)
|
|
);
|
|
pythonPackagesExtensions = prev.pythonPackagesExtensions ++ [
|
|
(pyFinal: pyPrev: {
|
|
haystack-ai = modify pyPrev.haystack-ai (
|
|
old:
|
|
let
|
|
version = "2.24.1";
|
|
in
|
|
(versionBumpAttrs old.version version {
|
|
inherit version;
|
|
|
|
src = final.fetchFromGitHub {
|
|
owner = "deepset-ai";
|
|
repo = "haystack";
|
|
rev = "v${version}";
|
|
hash = "sha256-tlQ3Bp+HcIsmoUoOMkm2APUSgNcdsujMUnSx+un/r8c=";
|
|
};
|
|
})
|
|
// {
|
|
propagatedBuildInputs =
|
|
(old.propagatedBuildInputs or [ ])
|
|
++ (with pyPrev; [
|
|
docstring-parser
|
|
filetype
|
|
jinja2
|
|
openai
|
|
])
|
|
++ [
|
|
pyFinal."haystack-experimental"
|
|
];
|
|
|
|
meta = (old.meta or { }) // {
|
|
broken = false;
|
|
};
|
|
}
|
|
);
|
|
sseclient-py = modify pyPrev.sseclient-py (old: rec {
|
|
format = "pyproject";
|
|
nativeBuildInputs =
|
|
(old.nativeBuildInputs or [ ])
|
|
++ (with pyPrev; [
|
|
hatchling
|
|
#pypaBuildHook
|
|
#pypaInstallHook
|
|
]);
|
|
doCheck = false;
|
|
});
|
|
vllm = modify pyPrev.vllm (
|
|
old:
|
|
let
|
|
version = "0.17.1";
|
|
in
|
|
versionBumpAttrs old.version version {
|
|
inherit version;
|
|
|
|
src = final.fetchFromGitHub {
|
|
owner = "vllm-project";
|
|
repo = "vllm";
|
|
rev = "v${version}";
|
|
hash = "sha256-EZozwA+GIjN8/CBNhtdeM3HsPhVdx1/J0B9gvvn2qKU=";
|
|
};
|
|
}
|
|
);
|
|
triton-xpu = pyFinal.buildPythonPackage rec {
|
|
pname = "pytorch_triton_xpu";
|
|
version = "3.5.0";
|
|
format = "wheel";
|
|
src = final.fetchurl {
|
|
url = "https://download.pytorch.org/whl/${pname}-${version}-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl";
|
|
hash = "sha256-DSTBcWCI8nZNDSTGQidzIZW2pCcGw8X8ie60kEv6CBg=";
|
|
};
|
|
build-system = with final.python3Packages; [
|
|
setuptools
|
|
];
|
|
nativeBuildInputs = (
|
|
with final;
|
|
[
|
|
autoPatchelfHook
|
|
]
|
|
);
|
|
buildInputs = [ final.zlib ];
|
|
postFixup = ''
|
|
substituteInPlace $out/${pyFinal.python.sitePackages}/triton/backends/intel/driver.py \
|
|
--replace-fail 'ze_root = os.getenv("ZE_PATH", default="/usr/local")' \
|
|
'ze_root = os.getenv("ZE_PATH", default="${final.level-zero}")'
|
|
substituteInPlace $out/${pyFinal.python.sitePackages}/triton/runtime/build.py \
|
|
--replace-fail 'icpx = shutil.which("icpx")' \
|
|
'icpx = "${final."intel-sycl".clang}/bin/clang++"'
|
|
'';
|
|
};
|
|
torch =
|
|
let
|
|
intelHwSrc = builtins.fetchGit {
|
|
url = "https://github.com/MordragT/nixos.git";
|
|
rev = "5fc6b35b8aafafbe9fa8bda6e0dc4ddbb0327b43";
|
|
};
|
|
torchDir = intelHwSrc + /pkgs/by-lang/intel-python/torch;
|
|
torchFn = import torchDir;
|
|
in
|
|
(torchFn {
|
|
inherit (final)
|
|
lib
|
|
cmake
|
|
which
|
|
pkg-config
|
|
breakpointHook
|
|
writeShellScript
|
|
;
|
|
inherit (final)
|
|
openssl
|
|
ocl-icd
|
|
opencl-headers
|
|
level-zero
|
|
;
|
|
inherit (final)
|
|
fetchFromGitHub
|
|
fetchFromGitLab
|
|
runCommand
|
|
callPackage
|
|
applyPatches
|
|
;
|
|
inherit (final.buildPackages) ninja;
|
|
inherit (pyFinal)
|
|
buildPythonPackage
|
|
python
|
|
pybind11
|
|
astunparse
|
|
expecttest
|
|
filelock
|
|
fsspec
|
|
hypothesis
|
|
jinja2
|
|
networkx
|
|
packaging
|
|
psutil
|
|
pyyaml
|
|
requests
|
|
sympy
|
|
types-dataclasses
|
|
typing-extensions
|
|
pillow
|
|
six
|
|
tensorboard
|
|
protobuf
|
|
;
|
|
intel-sycl = final."intel-sycl";
|
|
oneapi-dnn = final.oneapi-dnn;
|
|
pti-gpu = final.pti-gpu;
|
|
intel-compute-runtime = final.intel-compute-runtime;
|
|
triton-xpu = pyFinal.triton-xpu;
|
|
inherit (final) git-unroll binutils;
|
|
}).overrideAttrs
|
|
(old: {
|
|
buildInputs = (old.buildInputs or [ ]) ++ [
|
|
final.vulkan-headers
|
|
final.vulkan-loader
|
|
final.shaderc
|
|
];
|
|
env = (old.env or { }) // {
|
|
USE_VULKAN = "1";
|
|
USE_OPENMP = "1";
|
|
VULKAN_SDK = "${final.shaderc}";
|
|
USE_CUDNN = "0";
|
|
USE_CUDSS = "0";
|
|
USE_CUFILE = "0";
|
|
USE_CUSPARSELT = "0";
|
|
USE_STATIC_NCCL = "0";
|
|
USE_NVRTC = "0";
|
|
USE_ROCM = "0";
|
|
USE_RCCL = "0";
|
|
USE_MPS = "0";
|
|
USE_PYTORCH_METAL = "0";
|
|
USE_PYTORCH_METAL_EXPORT = "0";
|
|
USE_COREML_DELEGATE = "0";
|
|
USE_MAGMA = "0";
|
|
USE_NNPACK = "0";
|
|
USE_XNNPACK = "0";
|
|
USE_PYTORCH_QNNPACK = "0";
|
|
USE_SNPE = "0";
|
|
USE_NNAPI = "0";
|
|
USE_KINETO = "0";
|
|
USE_ITT = "0";
|
|
USE_DISTRIBUTED = "0";
|
|
USE_GLOO = "0";
|
|
USE_MPI = "0";
|
|
USE_TENSORPIPE = "0";
|
|
USE_UCC = "0";
|
|
CC = "${final."intel-sycl".compatStdenv.cc}/bin/clang";
|
|
CXX = "${final."intel-sycl".compatStdenv.cc}/bin/clang++";
|
|
};
|
|
});
|
|
})
|
|
];
|
|
lutris-unwrapped = modify prev.lutris-unwrapped (
|
|
old:
|
|
let
|
|
version = "0.5.22";
|
|
in
|
|
versionBumpAttrs old.version version {
|
|
inherit version;
|
|
src = prev.fetchFromGitHub {
|
|
owner = "lutris";
|
|
repo = "lutris";
|
|
tag = "v${version}";
|
|
hash = "sha256-4mNknvfJQJEPZjQoNdKLQcW4CI93D6BUDPj8LtD940A=";
|
|
};
|
|
}
|
|
);
|
|
winetricks = modify prev.winetricks (old: {
|
|
nativeBuildInputs = (old.nativeBuildInputs or [ ]) ++ [ final.makeWrapper ];
|
|
|
|
postFixup = (old.postFixup or "") + ''
|
|
wrapProgram "$out/bin/winetricks" \
|
|
--prefix PATH : "${final.lib.makeBinPath [ winePkg ]}" \
|
|
--set-default WINE "${winePkg}/bin/wine" \
|
|
--run 'wine_dir="$(${final.coreutils}/bin/dirname "$(${final.coreutils}/bin/readlink -f "$WINE")")"' \
|
|
--run ': "''${WINE_BIN:=$wine_dir/.wine}"' \
|
|
--run 'export WINE WINESERVER WINE_BIN WINESERVER_BIN'
|
|
'';
|
|
});
|
|
intel-openmp-nightly = modify prev.intel-openmp-nightly (
|
|
old:
|
|
let
|
|
cmakeSccacheAttrs = mkCmakeSccacheAttrs old;
|
|
in
|
|
cmakeSccacheAttrs
|
|
// {
|
|
cmakeFlags = (cmakeSccacheAttrs.cmakeFlags or [ ]);
|
|
}
|
|
);
|
|
intel-compute-runtime = modify prev.intel-compute-runtime (
|
|
old:
|
|
let
|
|
cmakeSccacheAttrs = mkCmakeSccacheAttrs old;
|
|
#
|
|
# Build against the drm/tip 7.0.0-rc4 kernel headers for xe driver ABI compatibility
|
|
kernelSrc = builtins.fetchGit {
|
|
url = "https://gitlab.freedesktop.org/drm/tip.git";
|
|
rev = "61409ba11a36fa5aff4ce0f0086a6026a43c5bce";
|
|
shallow = true;
|
|
};
|
|
kernelHeaders = final.runCommand "xe-kernel-headers" { } ''
|
|
mkdir -p $out/include/drm
|
|
cp -v ${kernelSrc}/include/drm/xe_drm.h $out/include/drm/ 2>/dev/null || true
|
|
cp -v ${kernelSrc}/include/uapi/drm/xe_drm.h $out/include/drm/ 2>/dev/null || true
|
|
# Also copy other drm headers the compute runtime might need
|
|
for f in ${kernelSrc}/include/drm/*.h ${kernelSrc}/include/uapi/drm/*.h; do
|
|
[ -f "$f" ] && cp -v "$f" $out/include/drm/ 2>/dev/null || true
|
|
done
|
|
'';
|
|
in
|
|
cmakeSccacheAttrs
|
|
// {
|
|
cmakeFlags = (cmakeSccacheAttrs.cmakeFlags or [ ]) ++ [
|
|
(prev.lib.cmakeBool "NEO_ENABLE_XE" true)
|
|
];
|
|
buildInputs = (old.buildInputs or [ ]) ++ [ kernelHeaders ];
|
|
postPatch = (old.postPatch or "") + ''
|
|
# Copy xe_drm.h from the drm/tip kernel into all compute-runtime header locations
|
|
if [ -f "${kernelHeaders}/include/drm/xe_drm.h" ]; then
|
|
for dest in \
|
|
third_party/uapi/drm-next/xe \
|
|
third_party/uapi/drm-uapi-helper/xe \
|
|
third_party/uapi-eudebug/drm \
|
|
; do
|
|
if [ -d "$dest" ]; then
|
|
cp -v "${kernelHeaders}/include/drm/xe_drm.h" "$dest/"
|
|
fi
|
|
done
|
|
fi
|
|
|
|
# Patch GMM resource creation failures to be non-fatal.
|
|
# intel-gmmlib can't create resource info for BMG on kernel 7.0 xe driver
|
|
# in certain initialization paths. Patch the abort and add null guards.
|
|
|
|
# 1. resource_info.cpp: return nullptr instead of aborting
|
|
sed -i 's/UNRECOVERABLE_IF(resourceInfo->peekHandle() == 0);/if(resourceInfo->peekHandle() == 0) { delete resourceInfo; return nullptr; }/' \
|
|
shared/source/gmm_helper/resource_info.cpp
|
|
|
|
# 2. gmm.cpp: change UNRECOVERABLE_IF to graceful return first (line 104)
|
|
sed -i 's/UNRECOVERABLE_IF(this->gmmResourceInfo == nullptr);/if (this->gmmResourceInfo == nullptr) { return; }/' \
|
|
shared/source/gmm_helper/gmm.cpp
|
|
|
|
# 3. gmm.cpp: add null checks after GmmResourceInfo::create calls that lack them
|
|
# Lines 76 and 85 (line 103 already handled by step 2 after the UNRECOVERABLE_IF replacement)
|
|
sed -i '76a\ if (this->gmmResourceInfo == nullptr) { return; }' \
|
|
shared/source/gmm_helper/gmm.cpp
|
|
sed -i '87a\ if (this->gmmResourceInfo == nullptr) { return; }' \
|
|
shared/source/gmm_helper/gmm.cpp
|
|
'';
|
|
}
|
|
);
|
|
umu-launcher-unwrapped = modify prev.umu-launcher-unwrapped rec {
|
|
version = "1.4.0";
|
|
|
|
src = prev.fetchFromGitHub {
|
|
inherit version;
|
|
owner = "Open-Wine-Components";
|
|
repo = "umu-launcher";
|
|
tag = version;
|
|
hash = "sha256-7BdA/iAAIn2NR/uLzxdvsIh5/1SZacSfkiXJVJBT3EQ=";
|
|
};
|
|
|
|
cargoDeps = prev.rustPlatform.fetchCargoVendor {
|
|
inherit src;
|
|
hash = "sha256-CVcbktCBRZGnEuDVvl2iJpRgKh+ShFe5mjT6oMHIjtQ=";
|
|
};
|
|
};
|
|
umu-launcher = prev.umu-launcher.override {
|
|
extraLibraries = prevPkgs: [ prevPkgs.zstd ];
|
|
};
|
|
}
|