From f50d1431add92272d97b44e0c393a5759bf426c3 Mon Sep 17 00:00:00 2001 From: Bouke van der Bijl Date: Tue, 21 Jan 2025 11:05:32 +0100 Subject: [PATCH] suitesparse: use cuda stdenv if enabled --- .../libraries/science/math/suitesparse/default.nix | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/pkgs/development/libraries/science/math/suitesparse/default.nix b/pkgs/development/libraries/science/math/suitesparse/default.nix index c840b25345c3d..b4df81f991065 100644 --- a/pkgs/development/libraries/science/math/suitesparse/default.nix +++ b/pkgs/development/libraries/science/math/suitesparse/default.nix @@ -15,7 +15,10 @@ openmp ? null, }: -stdenv.mkDerivation rec { +let + stdenv' = if enableCuda then cudaPackages.backendStdenv else stdenv; +in +stdenv'.mkDerivation rec { pname = "suitesparse"; version = "5.13.0"; @@ -35,7 +38,7 @@ stdenv.mkDerivation rec { nativeBuildInputs = [ ] - ++ lib.optionals stdenv.hostPlatform.isDarwin [ + ++ lib.optionals stdenv'.hostPlatform.isDarwin [ fixDarwinDylibNames ] ++ lib.optionals enableCuda [ @@ -53,7 +56,7 @@ stdenv.mkDerivation rec { gmp mpfr ] - ++ lib.optionals stdenv.cc.isClang [ + ++ lib.optionals stdenv'.cc.isClang [ openmp ] ++ lib.optionals enableCuda [ @@ -82,14 +85,14 @@ stdenv.mkDerivation rec { "CUDART_LIB=${lib.getLib cudaPackages.cuda_cudart}/lib/libcudart.so" "CUBLAS_LIB=${lib.getLib cudaPackages.libcublas}/lib/libcublas.so" ] - ++ lib.optionals stdenv.hostPlatform.isDarwin [ + ++ lib.optionals stdenv'.hostPlatform.isDarwin [ # Unless these are set, the build will attempt to use `Accelerate` on darwin, see: # https://github.com/DrTimothyAldenDavis/SuiteSparse/blob/v5.13.0/SuiteSparse_config/SuiteSparse_config.mk#L368 "BLAS=-lblas" "LAPACK=-llapack" ]; - env = lib.optionalAttrs stdenv.hostPlatform.isDarwin { + env = lib.optionalAttrs stdenv'.hostPlatform.isDarwin { # Ensure that there is enough space for the `fixDarwinDylibNames` hook to # update the install names of the output dylibs. NIX_LDFLAGS = "-headerpad_max_install_names";