{ intelPackages, writeText, strace, pocl, }: let stdenv = intelPackages.stdenv; hello_sycl = writeText "hello.cpp" '' #include class hello_world; int main(int argc, char** argv) try { auto device_selector = sycl::default_selector_v; sycl::queue queue(device_selector); std::cout << "Running on: " << queue.get_device().get_info() << std::endl; queue.submit([&] (sycl::handler& cgh) { auto os = sycl::stream{128, 128, cgh}; cgh.single_task([=]() { os << "Hello World! (on device)\n"; }); }); return 0; } catch (sycl::exception &e) { std::cout << "SYCL exception: " << e.what() << std::endl; return 0; // we expect to fail since no devices should be available; } ''; in stdenv.mkDerivation (finalAttrs: { version = "0.0.1"; name = "hello-sycl"; nativeBuildInputs = [ stdenv strace ]; src = hello_sycl; dontUnpack = true; dontConfigure = true; NIX_DEBUG = 0; buildPhase = '' cp $src hello.cpp set -x echo CXX=$CXX command -v $CXX $CXX -fsycl hello.cpp -o hello ./hello | tee test-output set +x ''; installPhase = '' cp test-output $out ''; passthru = { withPocl = finalAttrs.finalPackage.overrideAttrs (old: { nativeBuildInputs = old.nativeBuildInputs ++ [ pocl ]; env = (old.env or { }) // { POCL_DEBUG = "error,warn"; POCL_CACHE_DIR = "/build/pocl_cache"; # Make PoCL report Intel vendor id so oneapi SYCL works POCL_DRIVER_VERSION_OVERRIDE = "2024.18.6.0.02_160000"; POCL_CPU_VENDOR_ID_OVERRIDE = 32902; }; doInstallCheck = true; installCheckPhase = '' grep "Hello World! (on device)" $out ''; }); withIntel = finalAttrs.finalPackage.overrideAttrs (old: { env = (old.env or { }) // { OCL_ICD_VENDORS = intelPackages.compiler + "/etc/OpenCL/vendors"; }; doInstallCheck = true; installCheckPhase = '' grep "Hello World! (on device)" $out ''; }); }; })