From b0b2d00c7bc31cabe2167b5f5af4dcb6e926e599 Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Wed, 8 Apr 2026 15:18:51 +0100 Subject: [PATCH 1/6] python3Packages.lightgbm: use boost187 This regressed in 186f1b3fd624e63c99fe0780a6abcc84008887e9, which bumped nixpkgs `boost` alias to `boost189`. However, it explicitly needs boost187. --- pkgs/development/python-modules/lightgbm/default.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/development/python-modules/lightgbm/default.nix b/pkgs/development/python-modules/lightgbm/default.nix index 5409d1662452..6fbba4c436c6 100644 --- a/pkgs/development/python-modules/lightgbm/default.nix +++ b/pkgs/development/python-modules/lightgbm/default.nix @@ -18,7 +18,7 @@ # buildInputs llvmPackages, - boost, + boost187, ocl-icd, opencl-headers, @@ -85,7 +85,7 @@ buildPythonPackage rec { buildInputs = (lib.optionals stdenv.cc.isClang [ llvmPackages.openmp ]) ++ (lib.optionals gpuSupport [ - boost + boost187 ocl-icd opencl-headers ]) From e73227e28c4afbb7201ec13d5b0235af0d500cc8 Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Wed, 8 Apr 2026 15:42:57 +0100 Subject: [PATCH 2/6] python3Packages.lightgbm: fix lib_lightgbm.so location cmake installs lib_lightgbm.so into the wrong place, `$out/lib/python3.13/site-packages/lib/lib_lightgbm.so`, which is not part of the locations `lightgbm/libpath.py` considers. Instead of patching that file, which seems to have regressed, set the `__BUILD_FOR_PYTHON` `cmakeBool` (as in `pyproject.toml`), which causes the .so file to be placed to a location that will be considered for dlopen()'ing later, removing the need for any patching alltogether. The new location of the .so file is also more aligned with how other python packages in nixpkgs do it, `$out/lib/python3.13/site-packages/lightgbm/lib/lib_lightgbm.so`. --- .../python-modules/lightgbm/default.nix | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/pkgs/development/python-modules/lightgbm/default.nix b/pkgs/development/python-modules/lightgbm/default.nix index 6fbba4c436c6..46016b92469e 100644 --- a/pkgs/development/python-modules/lightgbm/default.nix +++ b/pkgs/development/python-modules/lightgbm/default.nix @@ -55,18 +55,6 @@ buildPythonPackage rec { hash = "sha256-yxxZcg61aTicC6dNFPUjUbVzr0ifIwAyocnzFPi6t/4="; }; - # Patch dll search path to fix proper discovery of lib_lightgbm.so - # Exception: Cannot find lightgbm library file in following paths: - # /nix/store/...-python3.13-lightgbm-4.6.0/lib/python3.13/site-packages/lib_lightgbm.so - # /nix/store/...-python3.13-lightgbm-4.6.0/lib/python3.13/site-packages/lightgbm/bin/lib_lightgbm.so - # /nix/store/...-python3.13-lightgbm-4.6.0/lib/python3.13/site-packages/lightgbm/lib/lib_lightgbm.so - postPatch = '' - substituteInPlace lightgbm/libpath.py \ - --replace-fail \ - 'curr_path.parents[0] / "lib",' \ - 'curr_path.parents[1] / "lib",' - ''; - build-system = [ scikit-build-core ]; @@ -102,6 +90,9 @@ buildPythonPackage rec { cmakeFlags = [ (lib.cmakeBool "USE_GPU" gpuSupport) (lib.cmakeBool "USE_CUDA" cudaSupport) + # Set in pyproject.toml for `cmake.args` in `[tool.scikit-build]`, + # but not set by our hooks. + (lib.cmakeBool "__BUILD_FOR_PYTHON" true) ]; optional-dependencies = { From 11056076185446fe8d8e563104ffa70827250215 Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Wed, 8 Apr 2026 16:09:19 +0100 Subject: [PATCH 3/6] python3Packages.lightgbm: fix cuda build nvcc needs `-std=c++14` to successfully compile. --- pkgs/development/python-modules/lightgbm/default.nix | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkgs/development/python-modules/lightgbm/default.nix b/pkgs/development/python-modules/lightgbm/default.nix index 46016b92469e..ca051551f394 100644 --- a/pkgs/development/python-modules/lightgbm/default.nix +++ b/pkgs/development/python-modules/lightgbm/default.nix @@ -93,6 +93,10 @@ buildPythonPackage rec { # Set in pyproject.toml for `cmake.args` in `[tool.scikit-build]`, # but not set by our hooks. (lib.cmakeBool "__BUILD_FOR_PYTHON" true) + ] + ++ lib.optionals cudaSupport [ + # build fails otherwise + (lib.cmakeFeature "CMAKE_CUDA_STANDARD" "14") ]; optional-dependencies = { From d31f834be0adb7faf2c246aac128a3e09b56f211 Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Wed, 8 Apr 2026 16:22:14 +0100 Subject: [PATCH 4/6] python3Packages.lightgbm: add flokli to maintainers --- pkgs/development/python-modules/lightgbm/default.nix | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pkgs/development/python-modules/lightgbm/default.nix b/pkgs/development/python-modules/lightgbm/default.nix index ca051551f394..c5ad41943771 100644 --- a/pkgs/development/python-modules/lightgbm/default.nix +++ b/pkgs/development/python-modules/lightgbm/default.nix @@ -125,6 +125,9 @@ buildPythonPackage rec { homepage = "https://github.com/lightgbm-org/LightGBM"; changelog = "https://github.com/lightgbm-org/LightGBM/releases/tag/v${version}"; license = lib.licenses.mit; - maintainers = with lib.maintainers; [ teh ]; + maintainers = with lib.maintainers; [ + flokli + teh + ]; }; } From 2fa06e7751f235ac10428167edc5caa3838bc1ba Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Wed, 8 Apr 2026 16:50:41 +0100 Subject: [PATCH 5/6] python3Packages.lightgbm: use finalAttrs --- pkgs/development/python-modules/lightgbm/default.nix | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pkgs/development/python-modules/lightgbm/default.nix b/pkgs/development/python-modules/lightgbm/default.nix index c5ad41943771..a53f669d90a7 100644 --- a/pkgs/development/python-modules/lightgbm/default.nix +++ b/pkgs/development/python-modules/lightgbm/default.nix @@ -42,7 +42,7 @@ assert gpuSupport -> !cudaSupport; assert cudaSupport -> !gpuSupport; -buildPythonPackage rec { +buildPythonPackage (finalAttrs: { inherit (pkgs.lightgbm) pname version @@ -51,7 +51,7 @@ buildPythonPackage rec { pyproject = true; src = fetchPypi { - inherit pname version; + inherit (finalAttrs) pname version; hash = "sha256-yxxZcg61aTicC6dNFPUjUbVzr0ifIwAyocnzFPi6t/4="; }; @@ -123,11 +123,11 @@ buildPythonPackage rec { meta = { description = "Fast, distributed, high performance gradient boosting (GBDT, GBRT, GBM or MART) framework"; homepage = "https://github.com/lightgbm-org/LightGBM"; - changelog = "https://github.com/lightgbm-org/LightGBM/releases/tag/v${version}"; + changelog = "https://github.com/lightgbm-org/LightGBM/releases/tag/v${finalAttrs.version}"; license = lib.licenses.mit; maintainers = with lib.maintainers; [ flokli teh ]; }; -} +}) From 23c177448c69887c8f8e3718a860ae6dcdb99528 Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Thu, 9 Apr 2026 23:41:36 +0100 Subject: [PATCH 6/6] python3Packages.lightgbm: override stdenv if built with cuda support From https://github.com/NixOS/nixpkgs/pull/507972#discussion_r3053161889: > [This prevents] the other stdenv and its cc from leaking into the > build. The latter is somewhat optional, but the leakage can result in, > on one hand, in mixing object files from different cc releases ("works > in practice but nobody offers guarantees"), and on the other in the > hypothetical possibility that cuda tools use up wrong cc. > > If lightgbm builds cuda kernel, it "should" conditionally override > stdenv, so far we don't have a better system to configure this > transparently to individual packages... --- pkgs/development/python-modules/lightgbm/default.nix | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pkgs/development/python-modules/lightgbm/default.nix b/pkgs/development/python-modules/lightgbm/default.nix index a53f669d90a7..57e90a429249 100644 --- a/pkgs/development/python-modules/lightgbm/default.nix +++ b/pkgs/development/python-modules/lightgbm/default.nix @@ -42,7 +42,10 @@ assert gpuSupport -> !cudaSupport; assert cudaSupport -> !gpuSupport; -buildPythonPackage (finalAttrs: { +let + effectiveStdenv = if cudaSupport then cudaPackages.backendStdenv else stdenv; +in +buildPythonPackage.override { stdenv = effectiveStdenv; } (finalAttrs: { inherit (pkgs.lightgbm) pname version