about summary refs log tree commit diff
path: root/pkgs/development/libraries/science/math
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/development/libraries/science/math')
-rw-r--r--pkgs/development/libraries/science/math/clblas/default.nix3
-rw-r--r--pkgs/development/libraries/science/math/clblast/default.nix4
-rw-r--r--pkgs/development/libraries/science/math/faiss/default.nix211
-rw-r--r--pkgs/development/libraries/science/math/faiss/tests.nix37
-rw-r--r--pkgs/development/libraries/science/math/itpp/default.nix2
-rw-r--r--pkgs/development/libraries/science/math/lcalc/default.nix2
-rw-r--r--pkgs/development/libraries/science/math/libtorch/bin.nix9
-rw-r--r--pkgs/development/libraries/science/math/magma/generic.nix16
-rw-r--r--pkgs/development/libraries/science/math/mkl/default.nix4
-rw-r--r--pkgs/development/libraries/science/math/mkl/test/default.nix4
-rw-r--r--pkgs/development/libraries/science/math/or-tools/default.nix64
-rw-r--r--pkgs/development/libraries/science/math/or-tools/fix-stringview-compile.patch36
-rw-r--r--pkgs/development/libraries/science/math/or-tools/offline.patch16
-rw-r--r--pkgs/development/libraries/science/math/osqp/default.nix2
-rw-r--r--pkgs/development/libraries/science/math/petsc/default.nix96
-rw-r--r--pkgs/development/libraries/science/math/petsc/filter_mpi_warnings.patch100
-rw-r--r--pkgs/development/libraries/science/math/scalapack/default.nix9
-rw-r--r--pkgs/development/libraries/science/math/suitesparse/default.nix14
-rw-r--r--pkgs/development/libraries/science/math/tiny-cuda-nn/default.nix20
19 files changed, 206 insertions, 443 deletions
diff --git a/pkgs/development/libraries/science/math/clblas/default.nix b/pkgs/development/libraries/science/math/clblas/default.nix
index e5ad0e3e63d9c..910c40a4e0c03 100644
--- a/pkgs/development/libraries/science/math/clblas/default.nix
+++ b/pkgs/development/libraries/science/math/clblas/default.nix
@@ -42,10 +42,9 @@ stdenv.mkDerivation rec {
      "-DBUILD_TEST=OFF"
   ];
 
-  nativeBuildInputs = [ cmake gfortran ];
+  nativeBuildInputs = [ cmake gfortran python3 ];
   buildInputs = [
     blas
-    python3
     boost
   ] ++ lib.optionals (!stdenv.isDarwin) [
     ocl-icd
diff --git a/pkgs/development/libraries/science/math/clblast/default.nix b/pkgs/development/libraries/science/math/clblast/default.nix
index a7c8d8faee4c0..3bf38086ca2fa 100644
--- a/pkgs/development/libraries/science/math/clblast/default.nix
+++ b/pkgs/development/libraries/science/math/clblast/default.nix
@@ -9,13 +9,13 @@
 
 stdenv.mkDerivation rec {
   pname = "clblast";
-  version = "1.6.2";
+  version = "1.6.3";
 
   src = fetchFromGitHub {
     owner = "CNugteren";
     repo = "CLBlast";
     rev = version;
-    hash = "sha256-S25g25Il6rzkpU9IqOFDDeEr3uYyt/uewZZAl09YSts=";
+    hash = "sha256-fzenYFCAQ0B2NQgh5OaErv/yNEzjznB6ogRapqfL6P4=";
   };
 
   nativeBuildInputs = [
diff --git a/pkgs/development/libraries/science/math/faiss/default.nix b/pkgs/development/libraries/science/math/faiss/default.nix
index 5af73735fdf60..9d0dea3ff6a12 100644
--- a/pkgs/development/libraries/science/math/faiss/default.nix
+++ b/pkgs/development/libraries/science/math/faiss/default.nix
@@ -1,107 +1,112 @@
-{ lib
-, config
-, fetchFromGitHub
-, symlinkJoin
-, stdenv
-, cmake
-, cudaPackages ? { }
-, cudaSupport ? config.cudaSupport
-, pythonSupport ? true
-, pythonPackages
-, llvmPackages
-, boost
-, blas
-, swig
-, addOpenGLRunpath
-, optLevel ? let
-    optLevels =
-      lib.optionals stdenv.hostPlatform.avx2Support [ "avx2" ]
-      ++ lib.optionals stdenv.hostPlatform.sse4_1Support [ "sse4" ]
-      ++ [ "generic" ];
-  in
-  # Choose the maximum available optimization level
-  builtins.head optLevels
-, faiss # To run demos in the tests
-, runCommand
+{
+  lib,
+  config,
+  fetchFromGitHub,
+  stdenv,
+  cmake,
+  cudaPackages ? { },
+  cudaSupport ? config.cudaSupport,
+  pythonSupport ? true,
+  pythonPackages,
+  llvmPackages,
+  blas,
+  swig,
+  autoAddDriverRunpath,
+  optLevel ?
+    let
+      optLevels =
+        lib.optionals stdenv.hostPlatform.avx2Support [ "avx2" ]
+        ++ lib.optionals stdenv.hostPlatform.sse4_1Support [ "sse4" ]
+        ++ [ "generic" ];
+    in
+    # Choose the maximum available optimization level
+    builtins.head optLevels,
+  faiss, # To run demos in the tests
+  runCommand,
 }@inputs:
 
 let
   pname = "faiss";
-  version = "1.7.4";
+  version = "1.8.0";
 
   inherit (cudaPackages) flags backendStdenv;
 
   stdenv = if cudaSupport then backendStdenv else inputs.stdenv;
 
-  cudaJoined = symlinkJoin {
-    name = "cuda-packages-unsplit";
-    paths = with cudaPackages; [
-      cuda_cudart # cuda_runtime.h
-      libcublas
-      libcurand
-      cuda_cccl
-    ] ++ lib.optionals (cudaPackages ? cuda_profiler_api) [
-      cuda_profiler_api # cuda_profiler_api.h
-    ] ++ lib.optionals (!(cudaPackages ? cuda_profiler_api)) [
-      cuda_nvprof # cuda_profiler_api.h
-    ];
-  };
+  cudaComponents = with cudaPackages; [
+    cuda_cudart # cuda_runtime.h
+    libcublas
+    libcurand
+    cuda_cccl
+
+    # cuda_profiler_api.h
+    (cudaPackages.cuda_profiler_api or cudaPackages.cuda_nvprof)
+  ];
 in
 stdenv.mkDerivation {
   inherit pname version;
 
-  outputs = [ "out" "demos" ];
+  outputs = [
+    "out"
+    "demos"
+    "dist"
+  ];
 
   src = fetchFromGitHub {
     owner = "facebookresearch";
     repo = pname;
     rev = "v${version}";
-    hash = "sha256-WSce9X6sLZmGM5F0ZkK54VqpIy8u1VB0e9/l78co29M=";
+    hash = "sha256-nS8nhkNGGb2oAJKfr/MIAZjAwMxBGbNd16/CkEtv67I=";
   };
 
-  buildInputs = [
-    blas
-    swig
-  ] ++ lib.optionals pythonSupport [
-    pythonPackages.setuptools
-    pythonPackages.pip
-    pythonPackages.wheel
-  ] ++ lib.optionals stdenv.cc.isClang [
-    llvmPackages.openmp
-  ] ++ lib.optionals cudaSupport [
-    cudaJoined
-  ];
-
-  propagatedBuildInputs = lib.optionals pythonSupport [
-    pythonPackages.numpy
-  ];
-
-  nativeBuildInputs = [ cmake ] ++ lib.optionals cudaSupport [
-    cudaPackages.cuda_nvcc
-    addOpenGLRunpath
-  ] ++ lib.optionals pythonSupport [
-    pythonPackages.python
-  ];
+  # Remove the following substituteInPlace when updating
+  # to a release that contains change from PR
+  # https://github.com/facebookresearch/faiss/issues/3239
+  # that fixes building faiss with swig 4.2.x
+  postPatch = ''
+    substituteInPlace faiss/python/swigfaiss.swig \
+      --replace-fail '#ifdef SWIGWORDSIZE64' '#if (__SIZEOF_LONG__ == 8)'
+  '';
 
-  passthru.extra-requires.all = [
-    pythonPackages.numpy
-  ];
+  nativeBuildInputs =
+    [ cmake ]
+    ++ lib.optionals cudaSupport [
+      cudaPackages.cuda_nvcc
+      autoAddDriverRunpath
+    ]
+    ++ lib.optionals pythonSupport [
+      pythonPackages.python
+      pythonPackages.setuptools
+      pythonPackages.pip
+      pythonPackages.wheel
+    ];
 
-  cmakeFlags = [
-    "-DFAISS_ENABLE_GPU=${if cudaSupport then "ON" else "OFF"}"
-    "-DFAISS_ENABLE_PYTHON=${if pythonSupport then "ON" else "OFF"}"
-    "-DFAISS_OPT_LEVEL=${optLevel}"
-  ] ++ lib.optionals cudaSupport [
-    "-DCMAKE_CUDA_ARCHITECTURES=${flags.cmakeCudaArchitecturesString}"
-    "-DCUDAToolkit_INCLUDE_DIR=${cudaJoined}/include"
-  ];
+  buildInputs =
+    [
+      blas
+      swig
+    ]
+    ++ lib.optionals pythonSupport [ pythonPackages.numpy ]
+    ++ lib.optionals stdenv.cc.isClang [ llvmPackages.openmp ]
+    ++ lib.optionals cudaSupport cudaComponents;
+
+  cmakeFlags =
+    [
+      (lib.cmakeBool "FAISS_ENABLE_GPU" cudaSupport)
+      (lib.cmakeBool "FAISS_ENABLE_PYTHON" pythonSupport)
+      (lib.cmakeFeature "FAISS_OPT_LEVEL" optLevel)
+    ]
+    ++ lib.optionals cudaSupport [
+      (lib.cmakeFeature "CMAKE_CUDA_ARCHITECTURES" flags.cmakeCudaArchitecturesString)
+    ];
 
-  buildFlags = [
-    "faiss"
-    "demo_ivfpq_indexing"
-  ] ++ lib.optionals pythonSupport [
-    "swigfaiss"
-  ];
+  buildFlags =
+    [ "faiss" ]
+    # This is just a demo app used as a test.
+    # Disabled because linkage fails:
+    # https://github.com/facebookresearch/faiss/issues/3484
+    ++ lib.optionals (!cudaSupport) [ "demo_ivfpq_indexing" ]
+    ++ lib.optionals pythonSupport [ "swigfaiss" ];
 
   # pip wheel->pip install commands copied over from opencv4
 
@@ -110,36 +115,30 @@ stdenv.mkDerivation {
      python -m pip wheel --verbose --no-index --no-deps --no-clean --no-build-isolation --wheel-dir dist .)
   '';
 
-  postInstall = ''
-    mkdir -p $demos/bin
-    cp ./demos/demo_ivfpq_indexing $demos/bin/
-  '' + lib.optionalString pythonSupport ''
-    mkdir -p $out/${pythonPackages.python.sitePackages}
-    (cd faiss/python && python -m pip install dist/*.whl --no-index --no-warn-script-location --prefix="$out" --no-cache)
-  '';
-
-  postFixup = lib.optionalString (pythonSupport && cudaSupport) ''
-    addOpenGLRunpath $out/${pythonPackages.python.sitePackages}/faiss/*.so
-    addOpenGLRunpath $demos/bin/*
-  '';
-
-  # Need buildPythonPackage for this one
-  # pythonImportsCheck = [
-  #   "faiss"
-  # ];
+  postInstall =
+    ''
+      mkdir -p $demos/bin
+      if [[ "$buildInputs" == *demo_ivfpq_indexing* ]] ; then
+        cp ./demos/demo_ivfpq_indexing $demos/bin/
+      fi
+    ''
+    + lib.optionalString pythonSupport ''
+      mkdir "$dist"
+      cp faiss/python/dist/*.whl "$dist/"
+    '';
 
   passthru = {
     inherit cudaSupport cudaPackages pythonSupport;
 
     tests = {
-      runDemos = runCommand "${pname}-run-demos"
-        { buildInputs = [ faiss.demos ]; }
-        # There are more demos, we run just the one that documentation mentions
-        ''
-          demo_ivfpq_indexing && touch $out
-        '';
-    } // lib.optionalAttrs pythonSupport {
-      pytest = pythonPackages.callPackage ./tests.nix { };
+      runDemos =
+        runCommand "${pname}-run-demos" { buildInputs = [ faiss.demos ]; }
+          # There are more demos, we run just the one that documentation mentions
+          ''
+            demo_ivfpq_indexing && touch $out
+          '';
+      pythonFaiss = pythonPackages.faiss;
+      pytest = pythonPackages.faiss.tests.pytest;
     };
   };
 
diff --git a/pkgs/development/libraries/science/math/faiss/tests.nix b/pkgs/development/libraries/science/math/faiss/tests.nix
deleted file mode 100644
index 858a980bfeaf3..0000000000000
--- a/pkgs/development/libraries/science/math/faiss/tests.nix
+++ /dev/null
@@ -1,37 +0,0 @@
-{ lib
-, buildPythonPackage
-, faiss
-, scipy
-, pytestCheckHook
-}:
-
-assert faiss.pythonSupport;
-
-buildPythonPackage {
-  pname = "faiss-pytest-suite";
-  inherit (faiss) version;
-
-  format = "other";
-
-  src = "${faiss.src}/tests";
-
-  dontBuild = true;
-  dontInstall = true;
-
-  # Tests that need GPUs and would fail in the sandbox
-  disabledTestPaths = lib.optionals faiss.cudaSupport [
-    "test_contrib.py"
-  ];
-
-  disabledTests = [
-    # https://github.com/facebookresearch/faiss/issues/2836
-    "test_update_codebooks_with_double"
-  ];
-
-  nativeCheckInputs = [
-    faiss
-    pytestCheckHook
-    scipy
-  ] ++
-  faiss.extra-requires.all;
-}
diff --git a/pkgs/development/libraries/science/math/itpp/default.nix b/pkgs/development/libraries/science/math/itpp/default.nix
index d2f6b1ee8aec4..a1a1ed8a69bc0 100644
--- a/pkgs/development/libraries/science/math/itpp/default.nix
+++ b/pkgs/development/libraries/science/math/itpp/default.nix
@@ -48,7 +48,7 @@ stdenv.mkDerivation rec {
     homepage = "https://itpp.sourceforge.net/";
     license = licenses.gpl3;
     platforms = platforms.unix;
-    maintainers = with maintainers; [ ];
+    maintainers = [ ];
     broken = stdenv.isDarwin; # never built on Hydra https://hydra.nixos.org/job/nixpkgs/trunk/itpp.x86_64-darwin
   };
 }
diff --git a/pkgs/development/libraries/science/math/lcalc/default.nix b/pkgs/development/libraries/science/math/lcalc/default.nix
index ebab7c00809ad..6ea1ca8f8e6c0 100644
--- a/pkgs/development/libraries/science/math/lcalc/default.nix
+++ b/pkgs/development/libraries/science/math/lcalc/default.nix
@@ -14,7 +14,7 @@ stdenv.mkDerivation rec {
     owner = "sagemath";
     repo = pname;
     rev = version;
-    sha256 = "sha256-RxWZ7T0I9zV7jUVnL6jV/PxEoU32KY7Q1UsOL5Lonuc=";
+    hash = "sha256-RxWZ7T0I9zV7jUVnL6jV/PxEoU32KY7Q1UsOL5Lonuc=";
   };
 
   nativeBuildInputs = [
diff --git a/pkgs/development/libraries/science/math/libtorch/bin.nix b/pkgs/development/libraries/science/math/libtorch/bin.nix
index 5b08cfa7dcf07..92050cd172834 100644
--- a/pkgs/development/libraries/science/math/libtorch/bin.nix
+++ b/pkgs/development/libraries/science/math/libtorch/bin.nix
@@ -4,12 +4,13 @@
 , lib
 , libcxx
 , llvmPackages
+, config
 
-, addOpenGLRunpath
+, addDriverRunpath
 , patchelf
 , fixDarwinDylibNames
 
-, cudaSupport
+, cudaSupport ? config.cudaSupport
 }:
 
 let
@@ -31,7 +32,7 @@ in stdenv.mkDerivation {
 
   nativeBuildInputs =
     if stdenv.isDarwin then [ fixDarwinDylibNames ]
-    else [ patchelf ] ++ lib.optionals cudaSupport [ addOpenGLRunpath ];
+    else [ patchelf ] ++ lib.optionals cudaSupport [ addDriverRunpath ];
 
   dontBuild = true;
   dontConfigure = true;
@@ -64,7 +65,7 @@ in stdenv.mkDerivation {
       echo "setting rpath for $lib..."
       patchelf --set-rpath "${rpath}:$out/lib" "$lib"
       ${lib.optionalString cudaSupport ''
-        addOpenGLRunpath "$lib"
+        addDriverRunpath "$lib"
       ''}
     done
   '' + lib.optionalString stdenv.isDarwin ''
diff --git a/pkgs/development/libraries/science/math/magma/generic.nix b/pkgs/development/libraries/science/math/magma/generic.nix
index a675142f361d4..08dac598f7d91 100644
--- a/pkgs/development/libraries/science/math/magma/generic.nix
+++ b/pkgs/development/libraries/science/math/magma/generic.nix
@@ -134,19 +134,15 @@ stdenv.mkDerivation {
     blas
     python3
   ] ++ lists.optionals cudaSupport (with effectiveCudaPackages; [
-    cuda_cudart.dev # cuda_runtime.h
-    cuda_cudart.lib # cudart
-    cuda_cudart.static # cudart_static
-    libcublas.dev # cublas_v2.h
-    libcublas.lib # cublas
-    libcusparse.dev # cusparse.h
-    libcusparse.lib # cusparse
+    cuda_cudart # cuda_runtime.h
+    libcublas # cublas_v2.h
+    libcusparse # cusparse.h
   ] ++ lists.optionals (cudaOlder "11.8") [
-    cuda_nvprof.dev # <cuda_profiler_api.h>
+    cuda_nvprof # <cuda_profiler_api.h>
   ] ++ lists.optionals (cudaAtLeast "11.8") [
-    cuda_profiler_api.dev # <cuda_profiler_api.h>
+    cuda_profiler_api # <cuda_profiler_api.h>
   ] ++ lists.optionals (cudaAtLeast "12.0") [
-    cuda_cccl.dev # <nv/target>
+    cuda_cccl # <nv/target>
   ]) ++ lists.optionals rocmSupport [
     rocmPackages.clr
     rocmPackages.hipblas
diff --git a/pkgs/development/libraries/science/math/mkl/default.nix b/pkgs/development/libraries/science/math/mkl/default.nix
index 90e6c05da77d0..607b6c89e40d1 100644
--- a/pkgs/development/libraries/science/math/mkl/default.nix
+++ b/pkgs/development/libraries/science/math/mkl/default.nix
@@ -5,7 +5,7 @@
 , fetchurl
 , rpmextract
 , _7zz
-, darwin
+, cctools
 , validatePkgConfig
 , enableStatic ? stdenv.hostPlatform.isStatic
 }:
@@ -72,7 +72,7 @@ in stdenvNoCC.mkDerivation ({
 
   nativeBuildInputs = [ validatePkgConfig ] ++ (if stdenvNoCC.isDarwin
     then
-      [ _7zz darwin.cctools ]
+      [ _7zz cctools ]
     else
       [ rpmextract ]);
 
diff --git a/pkgs/development/libraries/science/math/mkl/test/default.nix b/pkgs/development/libraries/science/math/mkl/test/default.nix
index cb3355260d127..1717e11e43d86 100644
--- a/pkgs/development/libraries/science/math/mkl/test/default.nix
+++ b/pkgs/development/libraries/science/math/mkl/test/default.nix
@@ -12,7 +12,9 @@ in stdenv.mkDerivation {
   pname = "mkl-test";
   version = mkl.version;
 
-  src = ./.;
+  unpackPhase = ''
+    cp ${./test.c} test.c
+  '';
 
   nativeBuildInputs = [ pkg-config ];
 
diff --git a/pkgs/development/libraries/science/math/or-tools/default.nix b/pkgs/development/libraries/science/math/or-tools/default.nix
index acb0ece75463c..cb4670204d112 100644
--- a/pkgs/development/libraries/science/math/or-tools/default.nix
+++ b/pkgs/development/libraries/science/math/or-tools/default.nix
@@ -6,7 +6,7 @@
 , eigen
 , ensureNewerSourcesForZipFilesHook
 , fetchFromGitHub
-, fetchpatch
+, substituteAll
 , glpk
 , lib
 , pkg-config
@@ -19,53 +19,57 @@
 , zlib
 }:
 
+let
+  pybind11_protobuf = fetchFromGitHub {
+    owner = "pybind";
+    repo = "pybind11_protobuf";
+    rev = "b713501f1da56d9b76c42f89efd00b97c26c9eac";
+    hash = "sha256-f6pzRWextH+7lm1xzyhx98wCIWH3lbhn59gSCcjsBVw=";
+  };
+in
 stdenv.mkDerivation rec {
   pname = "or-tools";
-  version = "9.4";
+  version = "9.7";
 
   src = fetchFromGitHub {
     owner = "google";
     repo = "or-tools";
     rev = "v${version}";
-    sha256 = "sha256-joWonJGuxlgHhXLznRhC1MDltQulXzpo4Do9dec1bLY=";
+    hash = "sha256-eHukf6TbY2dx7iEf8WfwfWsjDEubPtRO02ju0kHtASo=";
   };
+
   patches = [
-    # Disable test that requires external input: https://github.com/google/or-tools/issues/3429
-    (fetchpatch {
-      url = "https://github.com/google/or-tools/commit/7072ae92ec204afcbfce17d5360a5884c136ce90.patch";
-      hash = "sha256-iWE+atp308q7pC1L1FD6sK8LvWchZ3ofxvXssguozbM=";
-    })
-    # Fix test that broke in parallel builds: https://github.com/google/or-tools/issues/3461
-    (fetchpatch {
-      url = "https://github.com/google/or-tools/commit/a26602f24781e7bfcc39612568aa9f4010bb9736.patch";
-      hash = "sha256-gM0rW0xRXMYaCwltPK0ih5mdo3HtX6mKltJDHe4gbLc=";
+    (substituteAll {
+      src = ./offline.patch;
+      pybind11_protobuf = "../../pybind11_protobuf";
     })
-    # Backport fix in cmake test configuration where pip installs newer version from PyPi over local build,
-    #  breaking checkPhase: https://github.com/google/or-tools/issues/3260
-    (fetchpatch {
-      url = "https://github.com/google/or-tools/commit/edd1544375bd55f79168db315151a48faa548fa0.patch";
-      hash = "sha256-S//1YM3IoRCp3Ghg8zMF0XXgIpVmaw4gH8cVb9eUbqM=";
-    })
-    # Don't use non-existent member of string_view. Partial patch from commit
-    # https://github.com/google/or-tools/commit/c5a2fa1eb673bf652cb9ad4f5049d054b8166e17.patch
-    ./fix-stringview-compile.patch
   ];
 
   # or-tools normally attempts to build Protobuf for the build platform when
   # cross-compiling. Instead, just tell it where to find protoc.
   postPatch = ''
     echo "set(PROTOC_PRG $(type -p protoc))" > cmake/host.cmake
+
+    cp -R ${pybind11_protobuf} pybind11_protobuf
+    chmod -R u+w pybind11_protobuf
   '';
 
   cmakeFlags = [
     "-DBUILD_DEPS=OFF"
     "-DBUILD_PYTHON=ON"
     "-DBUILD_pybind11=OFF"
+    "-DBUILD_pybind11_protobuf=ON"
+    "-DCMAKE_INSTALL_BINDIR=bin"
+    "-DCMAKE_INSTALL_INCLUDEDIR=include"
+    "-DCMAKE_INSTALL_LIBDIR=lib"
     "-DFETCH_PYTHON_DEPS=OFF"
     "-DUSE_GLPK=ON"
     "-DUSE_SCIP=OFF"
     "-DPython3_EXECUTABLE=${python.pythonOnBuildForHost.interpreter}"
   ] ++ lib.optionals stdenv.isDarwin [ "-DCMAKE_MACOSX_RPATH=OFF" ];
+
+  strictDeps = true;
+
   nativeBuildInputs = [
     cmake
     ensureNewerSourcesForZipFilesHook
@@ -78,14 +82,18 @@ stdenv.mkDerivation rec {
   ] ++ (with python.pythonOnBuildForHost.pkgs; [
     pip
     mypy-protobuf
+    mypy
   ]);
   buildInputs = [
+    abseil-cpp
     bzip2
     cbc
     eigen
     glpk
     python.pkgs.absl-py
     python.pkgs.pybind11
+    python.pkgs.pytest
+    python.pkgs.scipy
     python.pkgs.setuptools
     python.pkgs.wheel
     re2
@@ -103,7 +111,19 @@ stdenv.mkDerivation rec {
     python.pkgs.virtualenv
   ];
 
-  doCheck = true;
+  env.NIX_CFLAGS_COMPILE = toString [
+    # fatal error: 'python/google/protobuf/proto_api.h' file not found
+    "-I${protobuf.src}"
+    # fatal error: 'pybind11_protobuf/native_proto_caster.h' file not found
+    "-I${pybind11_protobuf}"
+  ];
+
+  # some tests fail on linux and hang on darwin
+  doCheck = false;
+
+  preCheck = ''
+    export LD_LIBRARY_PATH=$LD_LIBRARY_PATH''${LD_LIBRARY_PATH:+:}$PWD/lib
+  '';
 
   # This extra configure step prevents the installer from littering
   # $out/bin with sample programs that only really function as tests,
diff --git a/pkgs/development/libraries/science/math/or-tools/fix-stringview-compile.patch b/pkgs/development/libraries/science/math/or-tools/fix-stringview-compile.patch
deleted file mode 100644
index 760ab80a38e4d..0000000000000
--- a/pkgs/development/libraries/science/math/or-tools/fix-stringview-compile.patch
+++ /dev/null
@@ -1,36 +0,0 @@
-diff --git a/ortools/lp_data/lp_parser.cc b/ortools/lp_data/lp_parser.cc
-index 58286306e5..bd26c019ab 100644
---- a/ortools/lp_data/lp_parser.cc
-+++ b/ortools/lp_data/lp_parser.cc
-@@ -185,7 +185,7 @@ bool LPParser::ParseIntegerVariablesList(StringPiece line) {
- 
- bool LPParser::ParseConstraint(StringPiece constraint) {
-   const StatusOr<ParsedConstraint> parsed_constraint_or_status =
--      ::operations_research::glop::ParseConstraint(constraint.as_string());
-+      ::operations_research::glop::ParseConstraint(constraint);
-   if (!parsed_constraint_or_status.ok()) return false;
-   const ParsedConstraint& parsed_constraint =
-       parsed_constraint_or_status.value();
-@@ -342,10 +342,9 @@ TokenType LPParser::ConsumeToken(StringPiece* sp) {
- 
- }  // namespace
- 
--StatusOr<ParsedConstraint> ParseConstraint(absl::string_view constraint_view) {
-+StatusOr<ParsedConstraint> ParseConstraint(absl::string_view constraint) {
-   ParsedConstraint parsed_constraint;
-   // Get the name, if present.
--  StringPiece constraint{constraint_view};
-   StringPiece constraint_copy{constraint};
-   std::string consumed_name;
-   Fractional consumed_coeff;
-@@ -413,8 +412,8 @@ StatusOr<ParsedConstraint> ParseConstraint(absl::string_view constraint_view) {
-     right_bound = consumed_coeff;
-     if (ConsumeToken(&constraint, &consumed_name, &consumed_coeff) !=
-         TokenType::END) {
--      return absl::InvalidArgumentError(absl::StrCat(
--          "End of input was expected, found: ", constraint.as_string()));
-+      return absl::InvalidArgumentError(
-+          absl::StrCat("End of input was expected, found: ", constraint));
-     }
-   }
- 
diff --git a/pkgs/development/libraries/science/math/or-tools/offline.patch b/pkgs/development/libraries/science/math/or-tools/offline.patch
new file mode 100644
index 0000000000000..1a2a4dbe3631b
--- /dev/null
+++ b/pkgs/development/libraries/science/math/or-tools/offline.patch
@@ -0,0 +1,16 @@
+diff --git a/cmake/dependencies/CMakeLists.txt b/cmake/dependencies/CMakeLists.txt
+index af3a28c113..ba92c3c55e 100644
+--- a/cmake/dependencies/CMakeLists.txt
++++ b/cmake/dependencies/CMakeLists.txt
+@@ -177,9 +177,8 @@ if(BUILD_PYTHON AND BUILD_pybind11_protobuf)
+   list(APPEND CMAKE_MESSAGE_INDENT "  ")
+   FetchContent_Declare(
+     pybind11_protobuf
+-    GIT_REPOSITORY "https://github.com/pybind/pybind11_protobuf.git"
+-    GIT_TAG "main"
+-    PATCH_COMMAND git apply --ignore-whitespace "${CMAKE_CURRENT_LIST_DIR}/../../patches/pybind11_protobuf.patch"
++    SOURCE_DIR @pybind11_protobuf@
++    PATCH_COMMAND patch -p1 < "${CMAKE_CURRENT_LIST_DIR}/../../patches/pybind11_protobuf.patch"
+   )
+   FetchContent_MakeAvailable(pybind11_protobuf)
+   list(POP_BACK CMAKE_MESSAGE_INDENT)
diff --git a/pkgs/development/libraries/science/math/osqp/default.nix b/pkgs/development/libraries/science/math/osqp/default.nix
index d308302e2c9f3..bcb1031684668 100644
--- a/pkgs/development/libraries/science/math/osqp/default.nix
+++ b/pkgs/development/libraries/science/math/osqp/default.nix
@@ -11,7 +11,7 @@ stdenv.mkDerivation rec {
     owner = "oxfordcontrol";
     repo = "osqp";
     rev = "v${version}";
-    sha256 = "sha256-enkK5EFyAeLaUnHNYS3oq43HsHY5IuSLgsYP0k/GW8c=";
+    hash = "sha256-enkK5EFyAeLaUnHNYS3oq43HsHY5IuSLgsYP0k/GW8c=";
     fetchSubmodules = true;
   };
 
diff --git a/pkgs/development/libraries/science/math/petsc/default.nix b/pkgs/development/libraries/science/math/petsc/default.nix
deleted file mode 100644
index c07250c660a33..0000000000000
--- a/pkgs/development/libraries/science/math/petsc/default.nix
+++ /dev/null
@@ -1,96 +0,0 @@
-{ lib
-, stdenv
-, fetchurl
-, darwin
-, gfortran
-, python3
-, blas
-, lapack
-, mpiSupport ? true
-, mpi                   # generic mpi dependency
-, openssh               # required for openmpi tests
-, petsc-withp4est ? false
-, p4est
-, zlib                  # propagated by p4est but required by petsc
-, petsc-optimized ? false
-, petsc-scalar-type ? "real"
-, petsc-precision ? "double"
-}:
-
-# This version of PETSc does not support a non-MPI p4est build
-assert petsc-withp4est -> p4est.mpiSupport;
-
-stdenv.mkDerivation rec {
-  pname = "petsc";
-  version = "3.19.4";
-
-  src = fetchurl {
-    url = "http://ftp.mcs.anl.gov/pub/petsc/release-snapshots/petsc-${version}.tar.gz";
-    sha256 = "sha256-fJQbcb5Sw7dkIU5JLfYBCdEvl/fYVMl6RN8MTZWLOQY=";
-  };
-
-  inherit mpiSupport;
-  withp4est = petsc-withp4est;
-
-  strictDeps = true;
-  nativeBuildInputs = [ python3 gfortran ]
-    ++ lib.optional mpiSupport mpi
-    ++ lib.optional (mpiSupport && mpi.pname == "openmpi") openssh
-  ;
-  buildInputs = [ blas lapack ]
-    ++ lib.optional withp4est p4est
-  ;
-
-  prePatch = lib.optionalString stdenv.isDarwin ''
-    substituteInPlace config/install.py \
-      --replace /usr/bin/install_name_tool ${darwin.cctools}/bin/install_name_tool
-  '';
-
-  # Both OpenMPI and MPICH get confused by the sandbox environment and spew errors like this (both to stdout and stderr):
-  #     [hwloc/linux] failed to find sysfs cpu topology directory, aborting linux discovery.
-  #     [1684747490.391106] [localhost:14258:0]       tcp_iface.c:837  UCX  ERROR opendir(/sys/class/net) failed: No such file or directory
-  # These messages contaminate test output, which makes the quicktest suite to fail. The patch adds filtering for these messages.
-  patches = [ ./filter_mpi_warnings.patch ];
-
-  preConfigure = ''
-    patchShebangs ./lib/petsc/bin
-    configureFlagsArray=(
-      $configureFlagsArray
-      ${if !mpiSupport then ''
-        "--with-mpi=0"
-      '' else ''
-        "--CC=mpicc"
-        "--with-cxx=mpicxx"
-        "--with-fc=mpif90"
-        "--with-mpi=1"
-      ''}
-      ${lib.optionalString withp4est ''
-        "--with-p4est=1"
-        "--with-zlib-include=${zlib.dev}/include"
-        "--with-zlib-lib=-L${zlib}/lib -lz"
-      ''}
-      "--with-blas=1"
-      "--with-lapack=1"
-      "--with-scalar-type=${petsc-scalar-type}"
-      "--with-precision=${petsc-precision}"
-      ${lib.optionalString petsc-optimized ''
-        "--with-debugging=0"
-        COPTFLAGS='-g -O3'
-        FOPTFLAGS='-g -O3'
-        CXXOPTFLAGS='-g -O3'
-      ''}
-    )
-  '';
-
-  configureScript = "python ./configure";
-
-  enableParallelBuilding = true;
-  doCheck = stdenv.hostPlatform == stdenv.buildPlatform;
-
-  meta = with lib; {
-    description = "Portable Extensible Toolkit for Scientific computation";
-    homepage = "https://www.mcs.anl.gov/petsc/index.html";
-    license = licenses.bsd2;
-    maintainers = with maintainers; [ cburstedde ];
-  };
-}
diff --git a/pkgs/development/libraries/science/math/petsc/filter_mpi_warnings.patch b/pkgs/development/libraries/science/math/petsc/filter_mpi_warnings.patch
deleted file mode 100644
index f3a34de9304e3..0000000000000
--- a/pkgs/development/libraries/science/math/petsc/filter_mpi_warnings.patch
+++ /dev/null
@@ -1,100 +0,0 @@
-diff --git a/src/snes/tutorials/makefile b/src/snes/tutorials/makefile
-index 672a62a..a5fd1c4 100644
---- a/src/snes/tutorials/makefile
-+++ b/src/snes/tutorials/makefile
-@@ -13,6 +13,7 @@ include ${PETSC_DIR}/lib/petsc/conf/rules
- #  these tests are used by the makefile in PETSC_DIR for basic tests of the install and should not be removed
- testex5f: ex5f.PETSc
- 	-@${MPIEXEC} -n 1 ${MPIEXEC_TAIL} ./ex5f -snes_rtol 1e-4 > ex5f_1.tmp 2>&1; \
-+        sed -i '/hwloc\/linux/d ; /ERROR scandir(\/sys\/class\/net) failed/d' ex5f_1.tmp; \
-         if (${DIFF} output/ex5f_1.testout ex5f_1.tmp > /dev/null 2>&1) then \
-           echo "Fortran example src/snes/tutorials/ex5f run successfully with 1 MPI process"; \
-         else \
-@@ -25,6 +26,7 @@ testex5f: ex5f.PETSc
-         ${MAKE} PETSC_ARCH=${PETSC_ARCH} PETSC_DIR=${PETSC_DIR} ex5f.rm;
- testex19: ex19.PETSc
- 	-@${MPIEXEC} -n 1 ${MPIEXEC_TAIL} ./ex19 -da_refine 3 -pc_type mg -ksp_type fgmres  > ex19_1.tmp 2>&1; \
-+        sed -i '/hwloc\/linux/d ; /ERROR scandir(\/sys\/class\/net) failed/d' ex19_1.tmp; \
-         if (${DIFF} output/ex19_1.testout ex19_1.tmp > /dev/null 2>&1) then \
-           echo "C/C++ example src/snes/tutorials/ex19 run successfully with 1 MPI process"; \
-         else \
-@@ -36,6 +38,7 @@ testex19: ex19.PETSc
-         ${RM} -f ex19_1.tmp;
- testex19_mpi:
- 	-@${MPIEXEC} -n 2 ${MPIEXEC_TAIL} ./ex19 -da_refine 3 -pc_type mg -ksp_type fgmres  > ex19_1.tmp 2>&1; \
-+        sed -i '/hwloc\/linux/d ; /ERROR scandir(\/sys\/class\/net) failed/d' ex19_1.tmp; \
-         if (${DIFF} output/ex19_1.testout ex19_1.tmp > /dev/null 2>&1) then \
-           echo "C/C++ example src/snes/tutorials/ex19 run successfully with 2 MPI processes"; \
-         else \
-@@ -48,6 +51,7 @@ testex19_mpi:
- #use unpreconditioned norm because HYPRE device installations use different AMG parameters
- runex19_hypre:
- 	-@${MPIEXEC} -n 2 ${MPIEXEC_TAIL} ./ex19 -da_refine 3 -snes_monitor_short -ksp_norm_type unpreconditioned -pc_type hypre > ex19_1.tmp 2>&1; \
-+        sed -i '/hwloc\/linux/d ; /ERROR scandir(\/sys\/class\/net) failed/d' ex19_1.tmp; \
-           if (${DIFF} output/ex19_hypre.out ex19_1.tmp) then \
-             echo "C/C++ example src/snes/tutorials/ex19 run successfully with hypre"; \
-           else  \
-@@ -57,6 +61,7 @@ runex19_hypre:
-           ${RM} -f ex19_1.tmp
- runex19_hypre_cuda:
- 	-@${MPIEXEC} -n 2 ${MPIEXEC_TAIL} ./ex19 -dm_vec_type cuda -dm_mat_type aijcusparse -da_refine 3 -snes_monitor_short -ksp_norm_type unpreconditioned -pc_type hypre > ex19_1.tmp 2>&1; \
-+        sed -i '/hwloc\/linux/d ; /ERROR scandir(\/sys\/class\/net) failed/d' ex19_1.tmp; \
- 	   if (${DIFF} output/ex19_hypre.out ex19_1.tmp) then \
-            echo "C/C++ example src/snes/tutorials/ex19 run successfully with hypre/cuda"; \
-            else  \
-@@ -66,6 +71,7 @@ runex19_hypre_cuda:
- 	   ${RM} -f ex19_1.tmp
- runex19_hypre_hip:
- 	-@${MPIEXEC} -n 2 ${MPIEXEC_TAIL} ./ex19 -dm_vec_type hip -da_refine 3 -snes_monitor_short -ksp_norm_type unpreconditioned -pc_type hypre > ex19_1.tmp 2>&1; \
-+        sed -i '/hwloc\/linux/d ; /ERROR scandir(\/sys\/class\/net) failed/d' ex19_1.tmp; \
- 	   if (${DIFF} output/ex19_hypre.out ex19_1.tmp) then \
-            echo "C/C++ example src/snes/tutorials/ex19 run successfully with hypre/hip"; \
-            else \
-@@ -75,6 +81,7 @@ runex19_hypre_hip:
- 	   ${RM} -f ex19_1.tmp
- runex19_cuda:
- 	-@${MPIEXEC} -n 1 ${MPIEXEC_TAIL} ./ex19 -snes_monitor -dm_mat_type seqaijcusparse -dm_vec_type seqcuda -pc_type gamg -pc_gamg_esteig_ksp_max_it 10 -ksp_monitor -mg_levels_ksp_max_it 3  > ex19_1.tmp 2>&1; \
-+        sed -i '/hwloc\/linux/d ; /ERROR scandir(\/sys\/class\/net) failed/d' ex19_1.tmp; \
- 	   if (${DIFF} output/ex19_cuda_1.out ex19_1.tmp) then \
-            echo "C/C++ example src/snes/tutorials/ex19 run successfully with cuda"; \
-            else  \
-@@ -84,6 +91,7 @@ runex19_cuda:
- 	   ${RM} -f ex19_1.tmp
- runex19_ml:
- 	-@${MPIEXEC} -n 2 ${MPIEXEC_TAIL} ./ex19 -da_refine 3 -snes_monitor_short -pc_type ml > ex19_1.tmp 2>&1; \
-+        sed -i '/hwloc\/linux/d ; /ERROR scandir(\/sys\/class\/net) failed/d' ex19_1.tmp; \
- 	   if (${DIFF} output/ex19_ml.out ex19_1.tmp) then  \
-            echo "C/C++ example src/snes/tutorials/ex19 run successfully with ml"; \
-            else \
-@@ -93,6 +101,7 @@ runex19_ml:
-            ${RM} -f ex19_1.tmp
- runex19_fieldsplit_mumps:
- 	-@${MPIEXEC} -n 2 ${MPIEXEC_TAIL} ./ex19 -pc_type fieldsplit -pc_fieldsplit_block_size 4 -pc_fieldsplit_type SCHUR -pc_fieldsplit_0_fields 0,1,2 -pc_fieldsplit_1_fields 3 -fieldsplit_0_pc_type lu -fieldsplit_1_pc_type lu -snes_monitor_short -ksp_monitor_short  -fieldsplit_0_pc_factor_mat_solver_type mumps -fieldsplit_1_pc_factor_mat_solver_type mumps > ex19_6.tmp 2>&1; \
-+        sed -i '/hwloc\/linux/d ; /ERROR scandir(\/sys\/class\/net) failed/d' ex19_6.tmp; \
- 	   if (${DIFF} output/ex19_fieldsplit_5.out ex19_6.tmp) then  \
-            echo "C/C++ example src/snes/tutorials/ex19 run successfully with mumps"; \
-            else  \
-@@ -102,6 +111,7 @@ runex19_fieldsplit_mumps:
-            ${RM} -f ex19_6.tmp
- runex19_superlu_dist:
- 	-@${MPIEXEC} -n 1 ${MPIEXEC_TAIL} ./ex19 -da_grid_x 20 -da_grid_y 20 -pc_type lu -pc_factor_mat_solver_type superlu_dist > ex19.tmp 2>&1; \
-+        sed -i '/hwloc\/linux/d ; /ERROR scandir(\/sys\/class\/net) failed/d' ex19.tmp; \
- 	   if (${DIFF} output/ex19_superlu.out ex19.tmp) then \
-            echo "C/C++ example src/snes/tutorials/ex19 run successfully with superlu_dist"; \
-            else  \
-@@ -111,6 +121,7 @@ runex19_superlu_dist:
- 	   ${RM} -f ex19.tmp
- runex19_suitesparse:
- 	-@${MPIEXEC} -n 1 ${MPIEXEC_TAIL} ./ex19 -da_refine 3 -snes_monitor_short -pc_type lu -pc_factor_mat_solver_type umfpack > ex19_1.tmp 2>&1; \
-+        sed -i '/hwloc\/linux/d ; /ERROR scandir(\/sys\/class\/net) failed/d' ex19_1.tmp; \
- 	   if (${DIFF} output/ex19_suitesparse.out ex19_1.tmp) then \
-            echo "C/C++ example src/snes/tutorials/ex19 run successfully with suitesparse"; \
-            else \
-@@ -120,6 +131,7 @@ runex19_suitesparse:
- 	   ${RM} -f ex19_1.tmp
- runex3k_kokkos: ex3k.PETSc
- 	-@OMP_PROC_BIND=false ${MPIEXEC} -n 2 ${MPIEXEC_TAIL} ./ex3k -view_initial -dm_vec_type kokkos -dm_mat_type aijkokkos -use_gpu_aware_mpi 0 -snes_monitor > ex3k_1.tmp 2>&1 ;\
-+        sed -i '/hwloc\/linux/d ; /ERROR scandir(\/sys\/class\/net) failed/d' ex3k_1.tmp; \
- 	if (${DIFF} output/ex3k_1.out ex3k_1.tmp) then \
-           echo "C/C++ example src/snes/tutorials/ex3k run successfully with kokkos-kernels"; \
-         else \
diff --git a/pkgs/development/libraries/science/math/scalapack/default.nix b/pkgs/development/libraries/science/math/scalapack/default.nix
index 2f8d3dbe15de3..f1e0f6cf5a128 100644
--- a/pkgs/development/libraries/science/math/scalapack/default.nix
+++ b/pkgs/development/libraries/science/math/scalapack/default.nix
@@ -52,10 +52,11 @@ stdenv.mkDerivation rec {
       -DLAPACK_LIBRARIES="-llapack"
       -DBLAS_LIBRARIES="-lblas"
       -DCMAKE_Fortran_COMPILER=${lib.getDev mpi}/bin/mpif90
-      ${lib.optionalString passthru.isILP64 ''
-        -DCMAKE_Fortran_FLAGS="-fdefault-integer-8"
-        -DCMAKE_C_FLAGS="-DInt=long"
-      ''}
+      -DCMAKE_C_FLAGS="${lib.concatStringsSep " " [
+            "-Wno-implicit-function-declaration"
+            (lib.optionalString passthru.isILP64 "-DInt=long")
+      ]}"
+      ${lib.optionalString passthru.isILP64 ''-DCMAKE_Fortran_FLAGS="-fdefault-integer-8"''}
       )
   '';
 
diff --git a/pkgs/development/libraries/science/math/suitesparse/default.nix b/pkgs/development/libraries/science/math/suitesparse/default.nix
index fcfd9b56a1b14..43623e8604b9b 100644
--- a/pkgs/development/libraries/science/math/suitesparse/default.nix
+++ b/pkgs/development/libraries/science/math/suitesparse/default.nix
@@ -36,17 +36,15 @@ stdenv.mkDerivation rec {
   buildInputs = assert (blas.isILP64 == lapack.isILP64); [
     blas lapack
     metis
-    gfortran.cc.lib
+    (lib.getLib gfortran.cc)
     gmp
     mpfr
   ] ++ lib.optionals stdenv.cc.isClang [
     openmp
   ] ++ lib.optionals enableCuda [
-    cudaPackages.cuda_cudart.dev
-    cudaPackages.cuda_cudart.lib
-    cudaPackages.cuda_cccl.dev
-    cudaPackages.libcublas.dev
-    cudaPackages.libcublas.lib
+    cudaPackages.cuda_cudart
+    cudaPackages.cuda_cccl
+    cudaPackages.libcublas
   ];
 
   preConfigure = ''
@@ -63,8 +61,8 @@ stdenv.mkDerivation rec {
     "CFLAGS=-DBLAS64"
   ] ++ lib.optionals enableCuda [
     "CUDA_PATH=${cudaPackages.cuda_nvcc}"
-    "CUDART_LIB=${cudaPackages.cuda_cudart.lib}/lib/libcudart.so"
-    "CUBLAS_LIB=${cudaPackages.libcublas.lib}/lib/libcublas.so"
+    "CUDART_LIB=${lib.getLib cudaPackages.cuda_cudart}/lib/libcudart.so"
+    "CUBLAS_LIB=${lib.getLib cudaPackages.libcublas}/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.13.0/SuiteSparse_config/SuiteSparse_config.mk#L368
diff --git a/pkgs/development/libraries/science/math/tiny-cuda-nn/default.nix b/pkgs/development/libraries/science/math/tiny-cuda-nn/default.nix
index e9367d416e325..bea271b0cef15 100644
--- a/pkgs/development/libraries/science/math/tiny-cuda-nn/default.nix
+++ b/pkgs/development/libraries/science/math/tiny-cuda-nn/default.nix
@@ -14,15 +14,15 @@
   inherit (cudaPackages) backendStdenv flags;
 
   cuda-common-redist = with cudaPackages; [
-    cuda_cudart.dev # cuda_runtime.h
-    cuda_cudart.lib
-    cuda_cccl.dev # <nv/target>
-    libcublas.dev # cublas_v2.h
-    libcublas.lib
-    libcusolver.dev # cusolverDn.h
-    libcusolver.lib
-    libcusparse.dev # cusparse.h
-    libcusparse.lib
+    (lib.getDev cuda_cudart) # cuda_runtime.h
+    (lib.getLib cuda_cudart)
+    (lib.getDev cuda_cccl) # <nv/target>
+    (lib.getDev libcublas) # cublas_v2.h
+    (lib.getLib libcublas)
+    (lib.getDev libcusolver) # cusolverDn.h
+    (lib.getLib libcusolver)
+    (lib.getDev libcusparse) # cusparse.h
+    (lib.getLib libcusparse)
   ];
 
   cuda-native-redist = symlinkJoin {
@@ -46,7 +46,7 @@ in
 
     src = fetchFromGitHub {
       owner = "NVlabs";
-      repo = finalAttrs.pname;
+      repo = "tiny-cuda-nn";
       rev = "v${finalAttrs.version}";
       fetchSubmodules = true;
       hash = "sha256-qW6Fk2GB71fvZSsfu+mykabSxEKvaikZ/pQQZUycOy0=";