From 23c177448c69887c8f8e3718a860ae6dcdb99528 Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Thu, 9 Apr 2026 23:41:36 +0100 Subject: [PATCH] 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