{ lib, stdenv, config, fetchFromGitHub, fetchpatch, cmake, gtest, doCheck ? true, cudaSupport ? config.cudaSupport or false, openclSupport ? false, mpiSupport ? false, javaWrapper ? false, hdfsSupport ? false, pythonLibrary ? false, rLibrary ? false, cudaPackages, opencl-headers, ocl-icd, boost, llvmPackages, openmpi, openjdk, swig, hadoop, R, rPackages, pandoc, python3Packages, }: assert doCheck -> !mpiSupport; assert openclSupport -> !cudaSupport; assert cudaSupport -> !openclSupport; stdenv.mkDerivation (finalAttrs: { # prefix with r when building the R library # The R package build results in a special binary file # that contains a subset of the .so file use for the CLI # and python version. In general, the CRAN version from # nixpkgs's r-modules should be used, but this non-standard # build allows for enabling CUDA support and other features # which aren't included in the CRAN release. Build with: # nix-build -E "with (import $NIXPKGS{}); \ # let \ # lgbm = lightgbm.override{rLibrary = true; doCheck = false;}; \ # in \ # rWrapper.override{ packages = [ lgbm ]; }" pname = lib.optionalString rLibrary "r-" + "lightgbm"; version = "4.6.0"; src = fetchFromGitHub { owner = "microsoft"; repo = "lightgbm"; tag = "v${finalAttrs.version}"; fetchSubmodules = true; hash = "sha256-vq/TlM87i1GNq0Rpy0OTulT9LF+uvi4PhOUz7ZNeceA="; }; patches = [ # Fix boost 1.83+ compatibility # https://github.com/microsoft/LightGBM/issues/6786 # Patch taken from https://github.com/conda-forge/lightgbm-feedstock/pull/69 (fetchpatch { name = "fix-boost-sha1"; url = "https://raw.githubusercontent.com/conda-forge/lightgbm-feedstock/68ca96d25d8a6f7281310a4ad3b8d5cdd01f067b/recipe/patches/0003-boost-sha1.patch"; hash = "sha256-Hw2YmoduOPri7O1XV2p/3Ny4hC8xq7Jq4zoSuKhVeVQ="; }) ]; # Skip APPLE in favor of linux build for .so files postPatch = '' export PROJECT_SOURCE_DIR=./ substituteInPlace CMakeLists.txt \ --replace-fail "find_package(GTest CONFIG)" "find_package(GTest REQUIRED)" \ --replace-fail "OpenCL_INCLUDE_DIRS}" "OpenCL_INCLUDE_DIRS}" \ --replace-fail "elseif(APPLE)" "elseif(APPLESKIP)" substituteInPlace \ external_libs/compute/include/boost/compute/cl.hpp \ external_libs/compute/include/boost/compute/cl_ext.hpp \ --replace-fail "include