From 19633bd254579a5f0f7ebc44b5517847caa4f7a2 Mon Sep 17 00:00:00 2001 From: ruro Date: Tue, 7 Jan 2025 04:24:20 +0300 Subject: [PATCH] suitesparse: use effectiveStdenv pattern for cudaSupport --- .../science/math/suitesparse/default.nix | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/pkgs/development/libraries/science/math/suitesparse/default.nix b/pkgs/development/libraries/science/math/suitesparse/default.nix index c840b25345c3..040e8682426d 100644 --- a/pkgs/development/libraries/science/math/suitesparse/default.nix +++ b/pkgs/development/libraries/science/math/suitesparse/default.nix @@ -13,9 +13,13 @@ enableCuda ? config.cudaSupport, cudaPackages, openmp ? null, -}: +}@inputs: -stdenv.mkDerivation rec { +let + stdenv = throw "Use effectiveStdenv instead"; + effectiveStdenv = if enableCuda then cudaPackages.backendStdenv else inputs.stdenv; +in +effectiveStdenv.mkDerivation rec { pname = "suitesparse"; version = "5.13.0"; @@ -35,7 +39,7 @@ stdenv.mkDerivation rec { nativeBuildInputs = [ ] - ++ lib.optionals stdenv.hostPlatform.isDarwin [ + ++ lib.optionals effectiveStdenv.hostPlatform.isDarwin [ fixDarwinDylibNames ] ++ lib.optionals enableCuda [ @@ -53,7 +57,7 @@ stdenv.mkDerivation rec { gmp mpfr ] - ++ lib.optionals stdenv.cc.isClang [ + ++ lib.optionals effectiveStdenv.cc.isClang [ openmp ] ++ lib.optionals enableCuda [ @@ -82,14 +86,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 effectiveStdenv.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 effectiveStdenv.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";