about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/libraries/science/math/suitesparse/default.nix
diff options
context:
space:
mode:
Diffstat (limited to 'nixpkgs/pkgs/development/libraries/science/math/suitesparse/default.nix')
-rw-r--r--nixpkgs/pkgs/development/libraries/science/math/suitesparse/default.nix74
1 files changed, 74 insertions, 0 deletions
diff --git a/nixpkgs/pkgs/development/libraries/science/math/suitesparse/default.nix b/nixpkgs/pkgs/development/libraries/science/math/suitesparse/default.nix
new file mode 100644
index 000000000000..f0c82e7190f9
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/math/suitesparse/default.nix
@@ -0,0 +1,74 @@
+{ lib, stdenv
+, fetchFromGitHub
+, gfortran
+, blas, lapack
+, metis
+, fixDarwinDylibNames
+, gmp
+, mpfr
+, enableCuda ? false
+, cudatoolkit
+}:
+
+stdenv.mkDerivation rec {
+  pname = "suitesparse";
+  version = "5.8.1";
+
+  outputs = [ "out" "dev" "doc" ];
+
+  src = fetchFromGitHub {
+    owner = "DrTimothyAldenDavis";
+    repo = "SuiteSparse";
+    rev = "v${version}";
+    sha256 = "0qjlyfxs8s48rs63c2fzspisgq1kk4bwkgnhmh125hgkdhrq2w1c";
+  };
+
+  nativeBuildInputs = [
+  ] ++ lib.optional stdenv.isDarwin fixDarwinDylibNames;
+
+  # Use compatible indexing for lapack and blas used
+  buildInputs = assert (blas.isILP64 == lapack.isILP64); [
+    blas lapack
+    metis
+    gfortran.cc.lib
+    gmp
+    mpfr
+  ] ++ lib.optional enableCuda cudatoolkit;
+
+  preConfigure = ''
+    # Mongoose and GraphBLAS are packaged separately
+    sed -i "Makefile" -e '/GraphBLAS\|Mongoose/d'
+  '';
+
+  makeFlags = [
+    "INSTALL=${placeholder "out"}"
+    "INSTALL_INCLUDE=${placeholder "dev"}/include"
+    "JOBS=$(NIX_BUILD_CORES)"
+    "MY_METIS_LIB=-lmetis"
+  ] ++ lib.optionals blas.isILP64 [
+    "CFLAGS=-DBLAS64"
+  ] ++ lib.optionals enableCuda [
+    "CUDA_PATH=${cudatoolkit}"
+    "CUDART_LIB=${cudatoolkit.lib}/lib/libcudart.so"
+    "CUBLAS_LIB=${cudatoolkit}/lib/libcublas.so"
+  ] ++ lib.optionals stdenv.isDarwin [
+    # Unless these are set, the build will attempt to use `Accelerate` on darwin, see:
+    # https://github.com/DrTimothyAldenDavis/SuiteSparse/blob/v5.8.1/SuiteSparse_config/SuiteSparse_config.mk#L368
+    "BLAS=-lblas"
+    "LAPACK=-llapack"
+  ]
+  ;
+
+  buildFlags = [
+    # Build individual shared libraries, not demos
+    "library"
+  ];
+
+  meta = with lib; {
+    homepage = "http://faculty.cse.tamu.edu/davis/suitesparse.html";
+    description = "A suite of sparse matrix algorithms";
+    license = with licenses; [ bsd2 gpl2Plus lgpl21Plus ];
+    maintainers = with maintainers; [ ttuegel ];
+    platforms = with platforms; unix;
+  };
+}