Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ 2 lib, 3 stdenv, 4 fetchFromGitHub, 5 gfortran, 6 blas, 7 lapack, 8 metis, 9 fixDarwinDylibNames, 10 gmp, 11 mpfr, 12 config, 13 enableCuda ? config.cudaSupport, 14 cudaPackages, 15 openmp ? null, 16}@inputs: 17 18let 19 stdenv = throw "Use effectiveStdenv instead"; 20 effectiveStdenv = if enableCuda then cudaPackages.backendStdenv else inputs.stdenv; 21in 22effectiveStdenv.mkDerivation rec { 23 pname = "suitesparse"; 24 version = "5.13.0"; 25 26 outputs = [ 27 "out" 28 "dev" 29 "doc" 30 ]; 31 32 src = fetchFromGitHub { 33 owner = "DrTimothyAldenDavis"; 34 repo = "SuiteSparse"; 35 rev = "v${version}"; 36 sha256 = "sha256-Anen1YtXsSPhk8DpA4JtADIz9m8oXFl9umlkb4iImf8="; 37 }; 38 39 nativeBuildInputs = [ 40 ] 41 ++ lib.optionals effectiveStdenv.hostPlatform.isDarwin [ 42 fixDarwinDylibNames 43 ] 44 ++ lib.optionals enableCuda [ 45 cudaPackages.cuda_nvcc 46 ]; 47 48 # Use compatible indexing for lapack and blas used 49 buildInputs = 50 assert (blas.isILP64 == lapack.isILP64); 51 [ 52 blas 53 lapack 54 metis 55 (lib.getLib gfortran.cc) 56 gmp 57 mpfr 58 ] 59 ++ lib.optionals effectiveStdenv.cc.isClang [ 60 openmp 61 ] 62 ++ lib.optionals enableCuda [ 63 cudaPackages.cuda_cudart 64 cudaPackages.cuda_cccl 65 cudaPackages.libcublas 66 ]; 67 68 preConfigure = '' 69 # Mongoose and GraphBLAS are packaged separately 70 sed -i "Makefile" -e '/GraphBLAS\|Mongoose/d' 71 ''; 72 73 makeFlags = [ 74 "INSTALL=${placeholder "out"}" 75 "INSTALL_INCLUDE=${placeholder "dev"}/include" 76 "JOBS=$(NIX_BUILD_CORES)" 77 "MY_METIS_LIB=-lmetis" 78 ] 79 ++ lib.optionals blas.isILP64 [ 80 "CFLAGS=-DBLAS64" 81 ] 82 ++ lib.optionals enableCuda [ 83 "CUDA_PATH=${cudaPackages.cuda_nvcc}" 84 "CUDART_LIB=${lib.getLib cudaPackages.cuda_cudart}/lib/libcudart.so" 85 "CUBLAS_LIB=${lib.getLib cudaPackages.libcublas}/lib/libcublas.so" 86 ] 87 ++ lib.optionals effectiveStdenv.hostPlatform.isDarwin [ 88 # Unless these are set, the build will attempt to use `Accelerate` on darwin, see: 89 # https://github.com/DrTimothyAldenDavis/SuiteSparse/blob/v5.13.0/SuiteSparse_config/SuiteSparse_config.mk#L368 90 "BLAS=-lblas" 91 "LAPACK=-llapack" 92 ]; 93 94 env = { 95 # in GCC14 these two warnings were promoted to error 96 # let's make them warnings again to fix the build failure 97 NIX_CFLAGS_COMPILE = "-Wno-error=implicit-function-declaration -Wno-error=incompatible-pointer-types"; 98 } 99 // lib.optionalAttrs effectiveStdenv.hostPlatform.isDarwin { 100 # Ensure that there is enough space for the `fixDarwinDylibNames` hook to 101 # update the install names of the output dylibs. 102 NIX_LDFLAGS = "-headerpad_max_install_names"; 103 }; 104 105 buildFlags = [ 106 # Build individual shared libraries, not demos 107 "library" 108 ]; 109 110 meta = with lib; { 111 homepage = "http://faculty.cse.tamu.edu/davis/suitesparse.html"; 112 description = "Suite of sparse matrix algorithms"; 113 license = with licenses; [ 114 bsd2 115 gpl2Plus 116 lgpl21Plus 117 ]; 118 maintainers = with maintainers; [ ttuegel ]; 119 platforms = with platforms; unix; 120 }; 121}