{ config, stdenv, lib, fetchFromGitHub, 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 }: assert doCheck -> !mpiSupport; assert openclSupport -> !cudaSupport; assert cudaSupport -> !openclSupport; stdenv.mkDerivation rec { pnameBase = "lightgbm"; # 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-" + pnameBase; version = "4.5.0"; src = fetchFromGitHub { owner = "microsoft"; repo = pnameBase; rev = "v${version}"; fetchSubmodules = true; hash = "sha256-nST6+/c3Y4/hqwgEUhx03gWtjxhlmUu1XKDCy2pSsvU="; }; nativeBuildInputs = [ cmake ] ++ lib.optionals stdenv.isDarwin [ llvmPackages.openmp ] ++ lib.optionals openclSupport [ opencl-headers ocl-icd boost ] ++ lib.optionals mpiSupport [ openmpi ] ++ lib.optionals hdfsSupport [ hadoop ] ++ lib.optionals (hdfsSupport || javaWrapper) [ openjdk ] ++ lib.optionals javaWrapper [ swig ] ++ lib.optionals rLibrary [ R pandoc ]; buildInputs = [ gtest ] ++ lib.optional cudaSupport cudaPackages.cudatoolkit; propagatedBuildInputs = lib.optionals rLibrary [ rPackages.data_table rPackages.markdown rPackages.rmarkdown rPackages.jsonlite rPackages.Matrix rPackages.R6 ]; # Skip APPLE in favor of linux build for .so files postPatch = '' export PROJECT_SOURCE_DIR=./ substituteInPlace CMakeLists.txt \ --replace "find_package(GTest CONFIG)" "find_package(GTest REQUIRED)" \ --replace "OpenCL_INCLUDE_DIRS}" "OpenCL_INCLUDE_DIRS}" \ --replace "elseif(APPLE)" "elseif(APPLESKIP)" substituteInPlace \ external_libs/compute/include/boost/compute/cl.hpp \ external_libs/compute/include/boost/compute/cl_ext.hpp \ --replace "include