about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/libraries/science
diff options
context:
space:
mode:
Diffstat (limited to 'nixpkgs/pkgs/development/libraries/science')
-rw-r--r--nixpkgs/pkgs/development/libraries/science/astronomy/cfitsio/darwin-rpath-universal.patch21
-rw-r--r--nixpkgs/pkgs/development/libraries/science/astronomy/cfitsio/default.nix59
-rw-r--r--nixpkgs/pkgs/development/libraries/science/astronomy/indilib/default.nix87
-rw-r--r--nixpkgs/pkgs/development/libraries/science/astronomy/indilib/indi-3rdparty.nix100
-rw-r--r--nixpkgs/pkgs/development/libraries/science/astronomy/indilib/indi-firmware.nix82
-rw-r--r--nixpkgs/pkgs/development/libraries/science/astronomy/indilib/indi-full.nix29
-rw-r--r--nixpkgs/pkgs/development/libraries/science/astronomy/indilib/indi-with-drivers.nix18
-rw-r--r--nixpkgs/pkgs/development/libraries/science/astronomy/libnova/default.nix25
-rw-r--r--nixpkgs/pkgs/development/libraries/science/astronomy/libxisf/0001-Fix-pkg-config-paths.patch23
-rw-r--r--nixpkgs/pkgs/development/libraries/science/astronomy/libxisf/default.nix53
-rw-r--r--nixpkgs/pkgs/development/libraries/science/astronomy/stellarsolver/default.nix30
-rw-r--r--nixpkgs/pkgs/development/libraries/science/astronomy/wcslib/default.nix30
-rw-r--r--nixpkgs/pkgs/development/libraries/science/benchmark/papi/default.nix28
-rw-r--r--nixpkgs/pkgs/development/libraries/science/biology/bicgl/default.nix33
-rw-r--r--nixpkgs/pkgs/development/libraries/science/biology/bicpl/default.nix30
-rw-r--r--nixpkgs/pkgs/development/libraries/science/biology/bpp-core/default.nix39
-rw-r--r--nixpkgs/pkgs/development/libraries/science/biology/bpp-phyl/default.nix29
-rw-r--r--nixpkgs/pkgs/development/libraries/science/biology/bpp-popgen/default.nix32
-rw-r--r--nixpkgs/pkgs/development/libraries/science/biology/bpp-seq/default.nix32
-rw-r--r--nixpkgs/pkgs/development/libraries/science/biology/ciftilib/default.nix39
-rw-r--r--nixpkgs/pkgs/development/libraries/science/biology/edlib/default.nix30
-rw-r--r--nixpkgs/pkgs/development/libraries/science/biology/elastix/default.nix26
-rw-r--r--nixpkgs/pkgs/development/libraries/science/biology/gifticlib/default.nix34
-rw-r--r--nixpkgs/pkgs/development/libraries/science/biology/htslib/default.nix52
-rw-r--r--nixpkgs/pkgs/development/libraries/science/biology/mirtk/default.nix72
-rw-r--r--nixpkgs/pkgs/development/libraries/science/biology/nifticlib/default.nix33
-rw-r--r--nixpkgs/pkgs/development/libraries/science/biology/oobicpl/default.nix39
-rw-r--r--nixpkgs/pkgs/development/libraries/science/chemistry/avogadrolibs/default.nix89
-rw-r--r--nixpkgs/pkgs/development/libraries/science/chemistry/avogadrolibs/fragments.patch13
-rw-r--r--nixpkgs/pkgs/development/libraries/science/chemistry/cppe/default.nix26
-rw-r--r--nixpkgs/pkgs/development/libraries/science/chemistry/dftd4/default.nix54
-rw-r--r--nixpkgs/pkgs/development/libraries/science/chemistry/harminv/default.nix42
-rw-r--r--nixpkgs/pkgs/development/libraries/science/chemistry/libGDSII/default.nix32
-rw-r--r--nixpkgs/pkgs/development/libraries/science/chemistry/libmsym/default.nix23
-rw-r--r--nixpkgs/pkgs/development/libraries/science/chemistry/libvdwxc/default.nix52
-rw-r--r--nixpkgs/pkgs/development/libraries/science/chemistry/mctc-lib/default.nix46
-rw-r--r--nixpkgs/pkgs/development/libraries/science/chemistry/mmtf-cpp/default.nix25
-rw-r--r--nixpkgs/pkgs/development/libraries/science/chemistry/molequeue/default.nix34
-rw-r--r--nixpkgs/pkgs/development/libraries/science/chemistry/mstore/default.nix43
-rw-r--r--nixpkgs/pkgs/development/libraries/science/chemistry/multicharge/default.nix53
-rw-r--r--nixpkgs/pkgs/development/libraries/science/chemistry/openmm/default.nix108
-rw-r--r--nixpkgs/pkgs/development/libraries/science/chemistry/plumed/default.nix34
-rw-r--r--nixpkgs/pkgs/development/libraries/science/chemistry/simple-dftd3/default.nix52
-rw-r--r--nixpkgs/pkgs/development/libraries/science/chemistry/simple-dftd3/python.nix42
-rw-r--r--nixpkgs/pkgs/development/libraries/science/chemistry/tblite/0001-fix-multicharge-dep-needed-for-static-compilation.patch31
-rw-r--r--nixpkgs/pkgs/development/libraries/science/chemistry/tblite/default.nix75
-rw-r--r--nixpkgs/pkgs/development/libraries/science/chemistry/tblite/python.nix61
-rw-r--r--nixpkgs/pkgs/development/libraries/science/chemistry/xcfun/default.nix30
-rw-r--r--nixpkgs/pkgs/development/libraries/science/electronics/coloquinte/default.nix38
-rw-r--r--nixpkgs/pkgs/development/libraries/science/electronics/qcsxcad/default.nix47
-rw-r--r--nixpkgs/pkgs/development/libraries/science/math/QuadProgpp/default.nix33
-rw-r--r--nixpkgs/pkgs/development/libraries/science/math/amd-blis/default.nix72
-rw-r--r--nixpkgs/pkgs/development/libraries/science/math/amd-libflame/default.nix62
-rw-r--r--nixpkgs/pkgs/development/libraries/science/math/arpack/default.nix68
-rw-r--r--nixpkgs/pkgs/development/libraries/science/math/blas/default.nix44
-rw-r--r--nixpkgs/pkgs/development/libraries/science/math/blis/default.nix64
-rw-r--r--nixpkgs/pkgs/development/libraries/science/math/bonmin/default.nix53
-rw-r--r--nixpkgs/pkgs/development/libraries/science/math/brial/default.nix46
-rw-r--r--nixpkgs/pkgs/development/libraries/science/math/cholmod-extra/default.nix35
-rw-r--r--nixpkgs/pkgs/development/libraries/science/math/clblas/default.nix68
-rw-r--r--nixpkgs/pkgs/development/libraries/science/math/clblas/platform.patch34
-rw-r--r--nixpkgs/pkgs/development/libraries/science/math/clblast/default.nix44
-rw-r--r--nixpkgs/pkgs/development/libraries/science/math/cliquer/default.nix39
-rw-r--r--nixpkgs/pkgs/development/libraries/science/math/clmagma/default.nix73
-rw-r--r--nixpkgs/pkgs/development/libraries/science/math/coin-utils/default.nix31
-rw-r--r--nixpkgs/pkgs/development/libraries/science/math/dbcsr/default.nix81
-rw-r--r--nixpkgs/pkgs/development/libraries/science/math/ecos/default.nix38
-rw-r--r--nixpkgs/pkgs/development/libraries/science/math/faiss/default.nix153
-rw-r--r--nixpkgs/pkgs/development/libraries/science/math/faiss/tests.nix37
-rw-r--r--nixpkgs/pkgs/development/libraries/science/math/flintqs/default.nix40
-rw-r--r--nixpkgs/pkgs/development/libraries/science/math/ipopt/default.nix43
-rw-r--r--nixpkgs/pkgs/development/libraries/science/math/itpp/default.nix53
-rw-r--r--nixpkgs/pkgs/development/libraries/science/math/latte-integrale/default.nix41
-rw-r--r--nixpkgs/pkgs/development/libraries/science/math/lcalc/default.nix41
-rw-r--r--nixpkgs/pkgs/development/libraries/science/math/libamplsolver/default.nix39
-rw-r--r--nixpkgs/pkgs/development/libraries/science/math/libamplsolver/libamplsolver-sharedlib.patch39
-rw-r--r--nixpkgs/pkgs/development/libraries/science/math/libbraiding/default.nix34
-rw-r--r--nixpkgs/pkgs/development/libraries/science/math/libhomfly/default.nix35
-rw-r--r--nixpkgs/pkgs/development/libraries/science/math/liblapack/default.nix83
-rw-r--r--nixpkgs/pkgs/development/libraries/science/math/liblbfgs/default.nix19
-rw-r--r--nixpkgs/pkgs/development/libraries/science/math/libtorch/bin.nix104
-rw-r--r--nixpkgs/pkgs/development/libraries/science/math/libtorch/binary-hashes.nix19
-rwxr-xr-xnixpkgs/pkgs/development/libraries/science/math/libtorch/prefetch.sh38
-rw-r--r--nixpkgs/pkgs/development/libraries/science/math/libtorch/test/CMakeLists.txt5
-rw-r--r--nixpkgs/pkgs/development/libraries/science/math/libtorch/test/default.nix51
-rw-r--r--nixpkgs/pkgs/development/libraries/science/math/libtorch/test/test.cpp20
-rw-r--r--nixpkgs/pkgs/development/libraries/science/math/lrs/default.nix26
-rw-r--r--nixpkgs/pkgs/development/libraries/science/math/m4ri/default.nix30
-rw-r--r--nixpkgs/pkgs/development/libraries/science/math/m4rie/default.nix41
-rw-r--r--nixpkgs/pkgs/development/libraries/science/math/magma/default.nix53
-rw-r--r--nixpkgs/pkgs/development/libraries/science/math/magma/generic.nix173
-rw-r--r--nixpkgs/pkgs/development/libraries/science/math/magma/releases.nix69
-rw-r--r--nixpkgs/pkgs/development/libraries/science/math/metis/default.nix25
-rw-r--r--nixpkgs/pkgs/development/libraries/science/math/mkl/default.nix184
-rw-r--r--nixpkgs/pkgs/development/libraries/science/math/mkl/test/default.nix41
-rw-r--r--nixpkgs/pkgs/development/libraries/science/math/mkl/test/test.c12
-rw-r--r--nixpkgs/pkgs/development/libraries/science/math/mongoose/default.nix69
-rw-r--r--nixpkgs/pkgs/development/libraries/science/math/openblas/default.nix269
-rw-r--r--nixpkgs/pkgs/development/libraries/science/math/openlibm/default.nix23
-rw-r--r--nixpkgs/pkgs/development/libraries/science/math/openspecfun/default.nix24
-rw-r--r--nixpkgs/pkgs/development/libraries/science/math/or-tools/default.nix126
-rw-r--r--nixpkgs/pkgs/development/libraries/science/math/or-tools/fix-stringview-compile.patch36
-rw-r--r--nixpkgs/pkgs/development/libraries/science/math/osi/default.nix44
-rw-r--r--nixpkgs/pkgs/development/libraries/science/math/osqp/default.nix27
-rw-r--r--nixpkgs/pkgs/development/libraries/science/math/p4est-sc/default.nix72
-rw-r--r--nixpkgs/pkgs/development/libraries/science/math/p4est/default.nix64
-rw-r--r--nixpkgs/pkgs/development/libraries/science/math/p4est/p4est-metis.patch26
-rw-r--r--nixpkgs/pkgs/development/libraries/science/math/parmetis/default.nix34
-rw-r--r--nixpkgs/pkgs/development/libraries/science/math/petsc/default.nix96
-rw-r--r--nixpkgs/pkgs/development/libraries/science/math/petsc/filter_mpi_warnings.patch100
-rw-r--r--nixpkgs/pkgs/development/libraries/science/math/planarity/default.nix30
-rw-r--r--nixpkgs/pkgs/development/libraries/science/math/rankwidth/default.nix27
-rw-r--r--nixpkgs/pkgs/development/libraries/science/math/rubiks/default.nix81
-rw-r--r--nixpkgs/pkgs/development/libraries/science/math/scalapack/default.nix75
-rw-r--r--nixpkgs/pkgs/development/libraries/science/math/scs/default.nix52
-rw-r--r--nixpkgs/pkgs/development/libraries/science/math/spooles/allocate.patch38
-rw-r--r--nixpkgs/pkgs/development/libraries/science/math/spooles/default.nix56
-rw-r--r--nixpkgs/pkgs/development/libraries/science/math/spooles/spooles.patch188
-rw-r--r--nixpkgs/pkgs/development/libraries/science/math/spooles/transform.patch43
-rw-r--r--nixpkgs/pkgs/development/libraries/science/math/suitesparse-graphblas/default.nix37
-rw-r--r--nixpkgs/pkgs/development/libraries/science/math/suitesparse/4.2.nix43
-rw-r--r--nixpkgs/pkgs/development/libraries/science/math/suitesparse/4.4.nix99
-rw-r--r--nixpkgs/pkgs/development/libraries/science/math/suitesparse/default.nix94
-rw-r--r--nixpkgs/pkgs/development/libraries/science/math/superlu/add-superlu-lib-as-dependency-for-the-unit-tests.patch7
-rw-r--r--nixpkgs/pkgs/development/libraries/science/math/superlu/default.nix44
-rw-r--r--nixpkgs/pkgs/development/libraries/science/math/sympow/clean-extra-logfile-output-from-pari.patch39
-rw-r--r--nixpkgs/pkgs/development/libraries/science/math/sympow/default.nix84
-rw-r--r--nixpkgs/pkgs/development/libraries/science/math/tensorflow-lite/default.nix108
-rw-r--r--nixpkgs/pkgs/development/libraries/science/math/tensorrt/extension.nix156
-rw-r--r--nixpkgs/pkgs/development/libraries/science/math/tiny-cuda-nn/default.nix163
-rw-r--r--nixpkgs/pkgs/development/libraries/science/math/trilinos/default.nix102
-rw-r--r--nixpkgs/pkgs/development/libraries/science/math/wcpg/default.nix44
-rw-r--r--nixpkgs/pkgs/development/libraries/science/math/zn_poly/default.nix64
-rw-r--r--nixpkgs/pkgs/development/libraries/science/networking/ns-3/default.nix143
-rw-r--r--nixpkgs/pkgs/development/libraries/science/robotics/edgetpu-compiler/default.nix59
-rw-r--r--nixpkgs/pkgs/development/libraries/science/robotics/ispike/default.nix26
136 files changed, 7500 insertions, 0 deletions
diff --git a/nixpkgs/pkgs/development/libraries/science/astronomy/cfitsio/darwin-rpath-universal.patch b/nixpkgs/pkgs/development/libraries/science/astronomy/cfitsio/darwin-rpath-universal.patch
new file mode 100644
index 000000000000..0ea3b55ef708
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/astronomy/cfitsio/darwin-rpath-universal.patch
@@ -0,0 +1,21 @@
+diff -ruN cfitsio/configure cfitsio-rpath-universal/configure
+--- cfitsio/configure	2018-05-09 21:16:00.000000000 +0200
++++ cfitsio-rpath-universal/configure	2021-10-27 12:02:25.000000000 +0200
+@@ -4829,16 +4829,7 @@
+     SHLIB_SUFFIX=".dylib"
+     CFITSIO_SHLIB="lib\${PACKAGE}.\${CFITSIO_SONAME}.\${CFITSIO_MAJOR}.\${CFITSIO_MINOR}\${SHLIB_SUFFIX}"
+     CFITSIO_SHLIB_SONAME="lib\${PACKAGE}.\${CFITSIO_SONAME}\${SHLIB_SUFFIX}"
+-    case $host in
+-        *darwin[56789]*)
+-            SHLIB_LD="$CC -dynamiclib -install_name lib\${PACKAGE}.\${CFITSIO_SONAME}\${SHLIB_SUFFIX} -compatibility_version \${CFITSIO_SONAME} -current_version \${CFITSIO_SONAME}.\${CFITSIO_MAJOR}.\${CFITSIO_MINOR}.\${CFITSIO_MICRO}"
+-            ;;
+-        *)
+-            # Build 'Universal' binaries (i386 & x86_64 architectures) and
+-            # use rpath token on Darwin 10.x or newer:
+-            SHLIB_LD="$CC -dynamiclib $C_UNIV_SWITCH -headerpad_max_install_names -install_name @rpath/lib\${PACKAGE}.\${CFITSIO_SONAME}\${SHLIB_SUFFIX} -compatibility_version \${CFITSIO_SONAME} -current_version \${CFITSIO_SONAME}.\${CFITSIO_MAJOR}.\${CFITSIO_MINOR}.\${CFITSIO_MICRO}"
+-            ;;
+-    esac
++    SHLIB_LD="$CC -dynamiclib -install_name ${out}/lib/lib\${PACKAGE}.\${CFITSIO_SONAME}\${SHLIB_SUFFIX} -compatibility_version \${CFITSIO_SONAME} -current_version \${CFITSIO_SONAME}.\${CFITSIO_MAJOR}.\${CFITSIO_MINOR}"
+ 
+     lhea_shlib_cflags="-fPIC -fno-common"
+     ;;
diff --git a/nixpkgs/pkgs/development/libraries/science/astronomy/cfitsio/default.nix b/nixpkgs/pkgs/development/libraries/science/astronomy/cfitsio/default.nix
new file mode 100644
index 000000000000..65f7d61d0269
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/astronomy/cfitsio/default.nix
@@ -0,0 +1,59 @@
+{ stdenv
+, lib
+, fetchurl
+, bzip2
+, curl
+, zlib
+}:
+
+stdenv.mkDerivation (finalAttrs: {
+  pname = "cfitsio";
+  version = "4.4.0";
+
+  src = fetchurl {
+    url = "https://heasarc.gsfc.nasa.gov/FTP/software/fitsio/c/cfitsio-${finalAttrs.version}.tar.gz";
+    hash = "sha256-lZAM+VrnYIOefLlninsvrQhY1qwSI0+TS9HLa/wka6k=";
+  };
+
+  patches = [
+    ./darwin-rpath-universal.patch
+  ];
+
+  buildInputs = [
+    bzip2
+    curl
+    zlib
+  ];
+
+  configureFlags = [
+    "--with-bzip2=${bzip2.out}"
+    "--enable-reentrant"
+  ];
+
+  hardeningDisable = [ "format" ];
+
+  # Shared-only build
+  buildFlags = [ "shared" ];
+
+  postPatch = ''
+    sed -e '/^install:/s/libcfitsio.a //' -e 's@/bin/@@g' -i Makefile.in
+  '';
+
+  meta = {
+    homepage = "https://heasarc.gsfc.nasa.gov/fitsio/";
+    description = "Library for reading and writing FITS data files";
+    longDescription = ''
+      CFITSIO is a library of C and Fortran subroutines for reading and
+      writing data files in FITS (Flexible Image Transport System) data
+      format.  CFITSIO provides simple high-level routines for reading and
+      writing FITS files that insulate the programmer from the internal
+      complexities of the FITS format.  CFITSIO also provides many
+      advanced features for manipulating and filtering the information in
+      FITS files.
+    '';
+    changelog = "https://heasarc.gsfc.nasa.gov/FTP/software/fitsio/c/docs/changes.txt";
+    license = lib.licenses.mit;
+    maintainers = with lib.maintainers; [ xbreak hjones2199 ];
+    platforms = lib.platforms.linux ++ lib.platforms.darwin;
+  };
+})
diff --git a/nixpkgs/pkgs/development/libraries/science/astronomy/indilib/default.nix b/nixpkgs/pkgs/development/libraries/science/astronomy/indilib/default.nix
new file mode 100644
index 000000000000..f0d25defe122
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/astronomy/indilib/default.nix
@@ -0,0 +1,87 @@
+{ stdenv
+, lib
+, fetchFromGitHub
+, bash
+, cmake
+, cfitsio
+, libusb1
+, kmod
+, zlib
+, boost
+, libev
+, libnova
+, curl
+, libjpeg
+, gsl
+, fftw
+, gtest
+, indi-full
+}:
+
+stdenv.mkDerivation (finalAttrs: {
+  pname = "indilib";
+  version = "2.0.6";
+
+  src = fetchFromGitHub {
+    owner = "indilib";
+    repo = "indi";
+    rev = "v${finalAttrs.version}";
+    hash = "sha256-3MeF2G/rr//c7cgGzqDzmqoNKvR+7Kkbid1g8znKPkg=";
+  };
+
+  nativeBuildInputs = [
+    cmake
+  ];
+
+  buildInputs = [
+    curl
+    cfitsio
+    libev
+    libusb1
+    zlib
+    boost
+    libnova
+    libjpeg
+    gsl
+    fftw
+  ];
+
+  cmakeFlags = [
+    "-DCMAKE_INSTALL_LIBDIR=lib"
+    "-DUDEVRULES_INSTALL_DIR=lib/udev/rules.d"
+  ] ++ lib.optional finalAttrs.finalPackage.doCheck [
+    "-DINDI_BUILD_UNITTESTS=ON"
+    "-DINDI_BUILD_INTEGTESTS=ON"
+  ];
+
+  checkInputs = [ gtest ];
+
+  doCheck = true;
+
+  # Socket address collisions between tests
+  enableParallelChecking = false;
+
+  postFixup = lib.optionalString stdenv.isLinux ''
+    for f in $out/lib/udev/rules.d/*.rules
+    do
+      substituteInPlace $f --replace "/bin/sh" "${bash}/bin/sh" \
+                           --replace "/sbin/modprobe" "${kmod}/sbin/modprobe"
+    done
+  '';
+
+  passthru.tests = {
+    # make sure 3rd party drivers compile with this indilib
+    indi-full = indi-full.override {
+      indilib = finalAttrs.finalPackage;
+    };
+  };
+
+  meta = with lib; {
+    homepage = "https://www.indilib.org/";
+    description = "Implementation of the INDI protocol for POSIX operating systems";
+    changelog = "https://github.com/indilib/indi/releases/tag/v${finalAttrs.version}";
+    license = licenses.lgpl2Plus;
+    maintainers = with maintainers; [ hjones2199 sheepforce ];
+    platforms = platforms.unix;
+  };
+})
diff --git a/nixpkgs/pkgs/development/libraries/science/astronomy/indilib/indi-3rdparty.nix b/nixpkgs/pkgs/development/libraries/science/astronomy/indilib/indi-3rdparty.nix
new file mode 100644
index 000000000000..9dafb64e9292
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/astronomy/indilib/indi-3rdparty.nix
@@ -0,0 +1,100 @@
+{ stdenv
+, lib
+, bash
+, cmake
+, coreutils
+, cfitsio
+, libusb1
+, zlib
+, boost
+, libnova
+, curl
+, libjpeg
+, gsl
+, fftw
+, indilib
+, libgphoto2
+, libraw
+, libftdi1
+, libdc1394
+, gpsd
+, ffmpeg
+, limesuite
+, pkg-config
+, zeromq
+, version
+, src
+, withFirmware ? false
+, firmware ? null
+}:
+
+let
+  libusb-with-fxload = libusb1.override { withExamples = true;};
+in
+
+stdenv.mkDerivation rec {
+  pname = "indi-3rdparty";
+
+  inherit version src;
+
+  nativeBuildInputs = [ cmake pkg-config ];
+
+  buildInputs = [
+    indilib libnova curl cfitsio libusb1 zlib boost gsl gpsd
+    libjpeg libgphoto2 libraw libftdi1 libdc1394 ffmpeg fftw
+    limesuite zeromq
+  ] ++ lib.optionals withFirmware [
+    firmware
+  ];
+
+  postPatch = ''
+    for f in $(find . -name "CMakeLists.txt"); do
+      substituteInPlace $f \
+        --replace "/lib/udev/rules.d" "lib/udev/rules.d" \
+        --replace "/etc/udev/rules.d" "lib/udev/rules.d" \
+        --replace "/lib/firmware" "lib/firmware"
+    done
+
+    substituteInPlace libpktriggercord/CMakeLists.txt \
+      --replace "set (PK_DATADIR /usr/share/pktriggercord)" "set (PK_DATADIR $out/share/pkgtriggercord)"
+
+    sed '1i#include <ctime>' -i indi-duino/libfirmata/src/firmata.cpp # gcc12
+  '';
+
+  cmakeFlags = [
+    "-DINDI_DATA_DIR=share/indi"
+    "-DCMAKE_INSTALL_LIBDIR=lib"
+    "-DUDEVRULES_INSTALL_DIR=lib/udev/rules.d"
+    "-DRULES_INSTALL_DIR=lib/udev/rules.d"
+  ] ++ lib.optionals (!withFirmware) [
+    "-DWITH_ATIK=off"
+    "-DWITH_APOGEE=off"
+    "-DWITH_DSI=off"
+    "-DWITH_QHY=off"
+    "-DWITH_ARMADILLO=off"
+    "-DWITH_FISHCAMP=off"
+    "-DWITH_SBIG=off"
+  ];
+
+  postFixup = lib.optionalString stdenv.isLinux ''
+    for f in $out/lib/udev/rules.d/*.rules
+    do
+      substituteInPlace $f --replace "/sbin/fxload" "${libusb-with-fxload}/sbin/fxload" \
+                           --replace "/lib/firmware/" "$out/lib/firmware/" \
+                           --replace "/bin/sleep" "${coreutils}/bin/sleep" \
+                           --replace "/bin/cat" "${coreutils}/bin/cat" \
+                           --replace "/bin/echo" "${coreutils}/bin/echo" \
+                           --replace "/bin/sh" "${bash}/bin/sh"
+    done
+  '';
+
+
+  meta = with lib; {
+    homepage = "https://www.indilib.org/";
+    description = "Third party drivers for the INDI astronomical software suite";
+    changelog = "https://github.com/indilib/indi-3rdparty/releases/tag/v${version}";
+    license = licenses.lgpl2Plus;
+    maintainers = with maintainers; [ hjones2199 sheepforce ];
+    platforms = platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/astronomy/indilib/indi-firmware.nix b/nixpkgs/pkgs/development/libraries/science/astronomy/indilib/indi-firmware.nix
new file mode 100644
index 000000000000..1eedfd3fea0b
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/astronomy/indilib/indi-firmware.nix
@@ -0,0 +1,82 @@
+{ stdenv
+, lib
+, bash
+, cmake
+, cfitsio
+, coreutils
+, libusb1
+, zlib
+, boost
+, libnova
+, curl
+, libjpeg
+, gsl
+, fftw
+, indilib
+, libgphoto2
+, libraw
+, libftdi1
+, libdc1394
+, gpsd
+, ffmpeg
+, version
+, src
+, autoPatchelfHook
+}:
+let
+  libusb-with-fxload = libusb1.override { withExamples = true;};
+in
+stdenv.mkDerivation rec {
+  pname = "indi-firmware";
+
+  inherit version src;
+
+  nativeBuildInputs = [ cmake autoPatchelfHook ];
+
+  buildInputs = [
+    indilib libnova curl cfitsio libusb1 zlib boost gsl gpsd
+    libjpeg libgphoto2 libraw libftdi1 libdc1394 ffmpeg fftw
+  ];
+
+  cmakeFlags = [
+    "-DINDI_DATA_DIR=\${CMAKE_INSTALL_PREFIX}/share/indi"
+    "-DCMAKE_INSTALL_LIBDIR=lib"
+    "-DUDEVRULES_INSTALL_DIR=lib/udev/rules.d"
+    "-DRULES_INSTALL_DIR=lib/udev/rules.d"
+    "-DFIRMWARE_INSTALL_DIR=lib/firmware"
+    "-DQHY_FIRMWARE_INSTALL_DIR=\${CMAKE_INSTALL_PREFIX}/lib/firmware/qhy"
+    "-DCONF_DIR=etc"
+    "-DBUILD_LIBS=1"
+    "-DWITH_PENTAX=off"
+    "-DWITH_AHP_XC=off"
+  ];
+
+  postPatch = ''
+    for f in {libfishcamp,libsbig,libqhy}/CMakeLists.txt
+    do
+      substituteInPlace $f --replace "/lib/firmware" "lib/firmware"
+    done
+  '';
+
+  postFixup = lib.optionalString stdenv.isLinux ''
+    for f in $out/lib/udev/rules.d/*.rules
+    do
+      substituteInPlace "$f" --replace "/sbin/fxload" "${libusb-with-fxload}/sbin/fxload" \
+                             --replace "/bin/sleep" "${coreutils}/bin/sleep" \
+                             --replace "/bin/cat" "${coreutils}/bin/cat" \
+                             --replace "/bin/echo" "${coreutils}/bin/echo" \
+                             --replace "/bin/sh" "${bash}/bin/sh" \
+                             --replace "/lib/firmware/" "$out/lib/firmware/"
+      sed -e 's|-D $env{DEVNAME}|-p $env{BUSNUM},$env{DEVNUM}|' -i "$f"
+    done
+  '';
+
+  meta = with lib; {
+    homepage = "https://www.indilib.org/";
+    description = "Third party firmware for the INDI astronomical software suite";
+    changelog = "https://github.com/indilib/indi-3rdparty/releases/tag/v${version}";
+    license = licenses.lgpl2Plus;
+    maintainers = with maintainers; [ hjones2199 sheepforce ];
+    platforms = platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/astronomy/indilib/indi-full.nix b/nixpkgs/pkgs/development/libraries/science/astronomy/indilib/indi-full.nix
new file mode 100644
index 000000000000..4dd80c3f0275
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/astronomy/indilib/indi-full.nix
@@ -0,0 +1,29 @@
+{ stdenv, lib, callPackage, fetchFromGitHub, indilib }:
+
+let
+  inherit (indilib) version;
+  indi-3rdparty-src = fetchFromGitHub {
+    owner = "indilib";
+    repo = "indi-3rdparty";
+    rev = "v${version}";
+    hash = "sha256-KNoyYldZWsXB9ubu0EYDgckRtpQgSCmzKlx7Erx4MRQ=";
+  };
+  indi-firmware = callPackage ./indi-firmware.nix {
+    inherit version;
+    src = indi-3rdparty-src;
+  };
+  indi-3rdparty = callPackage ./indi-3rdparty.nix {
+    inherit version;
+    src = indi-3rdparty-src;
+    withFirmware = stdenv.isx86_64 || stdenv.isAarch64;
+    firmware = indi-firmware;
+  };
+in
+callPackage ./indi-with-drivers.nix {
+  pname = "indi-full";
+  inherit version;
+  extraDrivers = [
+    indi-3rdparty
+  ] ++ lib.optional (stdenv.isx86_64 || stdenv.isAarch64) indi-firmware
+  ;
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/astronomy/indilib/indi-with-drivers.nix b/nixpkgs/pkgs/development/libraries/science/astronomy/indilib/indi-with-drivers.nix
new file mode 100644
index 000000000000..f1201df1d8a0
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/astronomy/indilib/indi-with-drivers.nix
@@ -0,0 +1,18 @@
+{ buildEnv, makeBinaryWrapper, indilib ? indilib, pname ? "indi-with-drivers", version ? null, extraDrivers ? null }:
+
+buildEnv {
+  name = "${pname}-${version}";
+  paths = [
+    indilib
+  ]
+  ++ extraDrivers;
+
+  nativeBuildInputs = [ makeBinaryWrapper ];
+
+  postBuild = ''
+    makeBinaryWrapper ${indilib}/bin/indiserver $out/bin/indiserver --set-default INDIPREFIX $out
+  '';
+
+
+  inherit (indilib) meta;
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/astronomy/libnova/default.nix b/nixpkgs/pkgs/development/libraries/science/astronomy/libnova/default.nix
new file mode 100644
index 000000000000..f6a8d01ab845
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/astronomy/libnova/default.nix
@@ -0,0 +1,25 @@
+{ lib, stdenv, fetchgit, autoreconfHook }:
+
+stdenv.mkDerivation rec {
+  pname = "libnova";
+  version = "0.16";
+
+  # pull from git repo because upstream stopped tarball releases after v0.15
+  src = fetchgit {
+    url = "https://git.code.sf.net/p/libnova/${pname}";
+    rev = "v${version}";
+    sha256 = "0icwylwkixihzni0kgl0j8dx3qhqvym6zv2hkw2dy6v9zvysrb1b";
+  };
+
+  nativeBuildInputs = [
+    autoreconfHook
+  ];
+
+  meta = with lib; {
+    description = "Celestial Mechanics, Astrometry and Astrodynamics Library";
+    homepage = "http://libnova.sf.net";
+    license = licenses.gpl2;
+    maintainers = with maintainers; [ hjones2199 ];
+    platforms = platforms.unix;
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/astronomy/libxisf/0001-Fix-pkg-config-paths.patch b/nixpkgs/pkgs/development/libraries/science/astronomy/libxisf/0001-Fix-pkg-config-paths.patch
new file mode 100644
index 000000000000..c26a2bbc8814
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/astronomy/libxisf/0001-Fix-pkg-config-paths.patch
@@ -0,0 +1,23 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Nicolas Benes <nbenes.gh@xandea.de>
+Date: Mon, 22 May 2023 09:25:27 +0200
+Subject: [PATCH] Fix pkg-config paths
+
+
+diff --git a/libxisf.pc.in b/libxisf.pc.in
+index b0b8b53..944b068 100644
+--- a/libxisf.pc.in
++++ b/libxisf.pc.in
+@@ -1,7 +1,7 @@
+ prefix="@CMAKE_INSTALL_PREFIX@"
+ exec_prefix="${prefix}"
+-libdir="${exec_prefix}/@CMAKE_INSTALL_LIBDIR@"
+-includedir="${prefix}/@CMAKE_INSTALL_INCLUDEDIR@"
++libdir="@CMAKE_INSTALL_FULL_LIBDIR@"
++includedir="@CMAKE_INSTALL_FULL_INCLUDEDIR@"
+ 
+ Name: @PROJECT_NAME@
+ Description: @CMAKE_PROJECT_DESCRIPTION@
+-- 
+2.38.5
+
diff --git a/nixpkgs/pkgs/development/libraries/science/astronomy/libxisf/default.nix b/nixpkgs/pkgs/development/libraries/science/astronomy/libxisf/default.nix
new file mode 100644
index 000000000000..19fb83ca78be
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/astronomy/libxisf/default.nix
@@ -0,0 +1,53 @@
+{ lib
+, stdenv
+, fetchFromGitea
+, cmake
+, pkg-config
+, lz4
+, pugixml
+, zlib
+, zstd
+}:
+
+stdenv.mkDerivation (finalAttrs: {
+  pname = "libxisf";
+  version = "0.2.11";
+
+  src = fetchFromGitea {
+    domain = "gitea.nouspiro.space";
+    owner = "nou";
+    repo = "libXISF";
+    rev = "v${finalAttrs.version}";
+    hash = "sha256-wXIbU9/xUyECluL6k1oKS3NBpoC/qjQdW9e485qmlgo=";
+  };
+
+  patches = [
+    ./0001-Fix-pkg-config-paths.patch
+  ];
+
+  nativeBuildInputs = [
+    cmake
+    pkg-config
+  ];
+
+  cmakeFlags = [
+    "-DUSE_BUNDLED_LIBS=OFF"
+  ] ++ lib.optional stdenv.hostPlatform.isStatic "-DBUILD_SHARED_LIBS=OFF";
+
+  buildInputs = [
+    lz4
+    pugixml
+    zlib
+    zstd
+  ];
+
+  doCheck = true;
+
+  meta = with lib; {
+    description = "Library to load and write XISF format from PixInsight";
+    homepage = "https://gitea.nouspiro.space/nou/libXISF";
+    license = licenses.gpl3Plus;
+    maintainers = with maintainers; [ panicgh ];
+    platforms = platforms.linux;
+  };
+})
diff --git a/nixpkgs/pkgs/development/libraries/science/astronomy/stellarsolver/default.nix b/nixpkgs/pkgs/development/libraries/science/astronomy/stellarsolver/default.nix
new file mode 100644
index 000000000000..8c6eb60d1d2b
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/astronomy/stellarsolver/default.nix
@@ -0,0 +1,30 @@
+{ lib, mkDerivation, fetchFromGitHub, cmake,
+  qtbase, cfitsio, gsl, wcslib, withTester ? false }:
+
+mkDerivation rec {
+  pname = "stellarsolver";
+  version = "2.5";
+
+  src = fetchFromGitHub {
+    owner = "rlancaste";
+    repo = pname;
+    rev = version;
+    sha256 = "sha256-0bFGHlkZnAZlnxlj8tY3s9yTWgkNtSsPFfudB3uvyOA=";
+  };
+
+  nativeBuildInputs = [ cmake ];
+
+  buildInputs = [ qtbase cfitsio gsl wcslib ];
+
+  cmakeFlags = [
+    "-DBUILD_TESTER=${if withTester then "on" else "off"}"
+  ];
+
+  meta = with lib; {
+    homepage = "https://github.com/rlancaste/stellarsolver";
+    description = "Astrometric plate solving library";
+    license = licenses.gpl3Plus;
+    maintainers = with maintainers; [ hjones2199 ];
+    platforms = platforms.unix;
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/astronomy/wcslib/default.nix b/nixpkgs/pkgs/development/libraries/science/astronomy/wcslib/default.nix
new file mode 100644
index 000000000000..a2bcdfdb7c34
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/astronomy/wcslib/default.nix
@@ -0,0 +1,30 @@
+{ lib, stdenv, fetchurl, flex }:
+
+stdenv.mkDerivation rec {
+  pname = "wcslib";
+  version = "8.2.2";
+
+  src = fetchurl {
+    url = "ftp://ftp.atnf.csiro.au/pub/software/wcslib/${pname}-${version}.tar.bz2";
+    sha256 = "sha256-YpgiCugX9OVSJkOsTD2iYjvnCjSEsaTzcGC+4+S9eDM=";
+  };
+
+  nativeBuildInputs = [ flex ];
+
+  enableParallelBuilding = true;
+
+  outputs = [ "out" "man" ];
+
+  meta = with lib; {
+    homepage = "https://www.atnf.csiro.au/people/mcalabre/WCS/";
+    description = "World Coordinate System library for astronomy";
+    longDescription = ''
+      Library for world coordinate systems for spherical geometries
+      and their conversion to image coordinate systems. This is the
+      standard library for this purpose in astronomy.
+    '';
+    maintainers = with maintainers; [ hjones2199 ];
+    license = licenses.lgpl3Plus;
+    platforms = platforms.unix;
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/benchmark/papi/default.nix b/nixpkgs/pkgs/development/libraries/science/benchmark/papi/default.nix
new file mode 100644
index 000000000000..7e022bafbb40
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/benchmark/papi/default.nix
@@ -0,0 +1,28 @@
+{ lib, stdenv
+, fetchurl
+}:
+
+stdenv.mkDerivation rec {
+  version = "7.0.1";
+  pname = "papi";
+
+  src = fetchurl {
+    url = "https://bitbucket.org/icl/papi/get/papi-${lib.replaceStrings ["."] ["-"] version}-t.tar.gz";
+    sha256 = "sha256-VajhmPW8sEJksfhLjBVlpBH7+AZr4fwKZPAtZxRF1Bk=";
+  };
+
+  setSourceRoot = ''
+    sourceRoot=$(echo */src)
+  '';
+
+  doCheck = true;
+  checkTarget = "test";
+
+  meta = with lib; {
+    homepage = "https://icl.utk.edu/papi/";
+    description = "Library providing access to various hardware performance counters";
+    license = licenses.bsdOriginal;
+    platforms = platforms.linux;
+    maintainers = with maintainers; [ costrouc zhaofengli ];
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/biology/bicgl/default.nix b/nixpkgs/pkgs/development/libraries/science/biology/bicgl/default.nix
new file mode 100644
index 000000000000..4f98874b2595
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/biology/bicgl/default.nix
@@ -0,0 +1,33 @@
+{ lib, stdenv, fetchFromGitHub, cmake, libminc, bicpl, freeglut, mesa_glu, GLUT }:
+
+stdenv.mkDerivation rec {
+  pname = "bicgl";
+  version = "unstable-2018-04-06";
+
+  owner = "BIC-MNI";
+
+  src = fetchFromGitHub {
+    inherit owner;
+    repo = pname;
+    rev = "61a035751c9244fcca1edf94d6566fa2a709ce90";
+    sha256 = "0lzirdi1mf4yl8srq7vjn746sbydz7h0wjh7wy8gycy6hq04qrg4";
+  };
+
+  nativeBuildInputs = [ cmake ];
+  buildInputs = [ libminc bicpl mesa_glu ]
+    ++ lib.optionals stdenv.isDarwin [ GLUT ]
+    ++ lib.optionals stdenv.isLinux [ freeglut ];
+
+  cmakeFlags = [
+    "-DLIBMINC_DIR=${libminc}/lib/cmake"
+    "-DBICPL_DIR=${bicpl}/lib"
+  ];
+
+  meta = with lib; {
+    homepage = "https://github.com/${owner}/${pname}";
+    description = "Brain Imaging Centre graphics library";
+    maintainers = with maintainers; [ bcdarwin ];
+    platforms = platforms.unix;
+    license = licenses.free;
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/biology/bicpl/default.nix b/nixpkgs/pkgs/development/libraries/science/biology/bicpl/default.nix
new file mode 100644
index 000000000000..5cf63e342242
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/biology/bicpl/default.nix
@@ -0,0 +1,30 @@
+{ lib, stdenv, fetchFromGitHub, cmake, libminc, netpbm }:
+
+stdenv.mkDerivation rec {
+  pname = "bicpl";
+  version = "unstable-2020-10-15";
+
+  # current master is significantly ahead of most recent release, so use Git version:
+  src = fetchFromGitHub {
+    owner  = "BIC-MNI";
+    repo   = pname;
+    rev    = "a58af912a71a4c62014975b89ef37a8e72de3c9d";
+    sha256 = "0iw0pmr8xrifbx5l8a0xidfqbm1v8hwzqrw0lcmimxlzdihyri0g";
+  };
+
+  nativeBuildInputs = [ cmake ];
+  buildInputs = [ libminc netpbm ];
+
+  cmakeFlags = [ "-DLIBMINC_DIR=${libminc}/lib/cmake" ];
+
+  doCheck = false;
+  # internal_volume_io.h: No such file or directory
+
+  meta = with lib; {
+    homepage = "https://github.com/BIC-MNI/bicpl";
+    description = "Brain Imaging Centre programming library";
+    maintainers = with maintainers; [ bcdarwin ];
+    platforms = platforms.unix;
+    license   = licenses.free;
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/biology/bpp-core/default.nix b/nixpkgs/pkgs/development/libraries/science/biology/bpp-core/default.nix
new file mode 100644
index 000000000000..0d0e3c114920
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/biology/bpp-core/default.nix
@@ -0,0 +1,39 @@
+{ lib, stdenv, fetchFromGitHub, fetchpatch, cmake }:
+
+stdenv.mkDerivation rec {
+  pname = "bpp-core";
+  version = "2.4.1";
+
+  src = fetchFromGitHub { owner = "BioPP";
+    repo = pname;
+    rev = "v${version}";
+    sha256 = "0ma2cl677l7s0n5sffh66cy9lxp5wycm50f121g8rx85p95vkgwv";
+  };
+
+  patches = [
+    (fetchpatch {
+      url = "https://github.com/BioPP/bpp-core/commit/d450e8033b06e80dff9c2236fb7ce1f3ced5dcbb.patch";
+      hash = "sha256-9t68mrK7KNs5BxljKMaA+XskCcKDNv8DNCVUYunoNdw=";
+    })
+  ];
+
+  nativeBuildInputs = [ cmake ];
+
+  postFixup = ''
+    substituteInPlace $out/lib/cmake/bpp-core/bpp-core-targets.cmake  \
+      --replace 'set(_IMPORT_PREFIX' '#set(_IMPORT_PREFIX'
+  '';
+  # prevents cmake from exporting incorrect INTERFACE_INCLUDE_DIRECTORIES
+  # of form /nix/store/.../nix/store/.../include,
+  # probably due to relative vs absolute path issue
+
+  doCheck = !stdenv.isDarwin;
+
+  meta = with lib; {
+    homepage = "https://github.com/BioPP/bpp-core";
+    changelog = "https://github.com/BioPP/bpp-core/blob/master/ChangeLog";
+    description = "C++ bioinformatics libraries and tools";
+    maintainers = with maintainers; [ bcdarwin ];
+    license = licenses.cecill20;
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/biology/bpp-phyl/default.nix b/nixpkgs/pkgs/development/libraries/science/biology/bpp-phyl/default.nix
new file mode 100644
index 000000000000..0b18dbfcf19a
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/biology/bpp-phyl/default.nix
@@ -0,0 +1,29 @@
+{ stdenv, fetchFromGitHub, cmake, bpp-core, bpp-seq }:
+
+stdenv.mkDerivation rec {
+  pname = "bpp-phyl";
+
+  inherit (bpp-core) version;
+
+  src = fetchFromGitHub {
+    owner = "BioPP";
+    repo = pname;
+    rev = "v${version}";
+    sha256 = "192zks6wyk903n06c2lbsscdhkjnfwms8p7jblsmk3lvjhdipb20";
+  };
+
+  nativeBuildInputs = [ cmake ];
+  buildInputs = [ bpp-core bpp-seq ];
+
+  postFixup = ''
+    substituteInPlace $out/lib/cmake/${pname}/${pname}-targets.cmake  \
+      --replace 'set(_IMPORT_PREFIX' '#set(_IMPORT_PREFIX'
+  '';
+
+  doCheck = !stdenv.isDarwin;
+
+  meta = bpp-core.meta // {
+    homepage = "https://github.com/BioPP/bpp-phyl";
+    changelog = "https://github.com/BioPP/bpp-phyl/blob/master/ChangeLog";
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/biology/bpp-popgen/default.nix b/nixpkgs/pkgs/development/libraries/science/biology/bpp-popgen/default.nix
new file mode 100644
index 000000000000..2cb89b4bbd38
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/biology/bpp-popgen/default.nix
@@ -0,0 +1,32 @@
+{ stdenv, fetchFromGitHub, cmake, bpp-core, bpp-seq }:
+
+stdenv.mkDerivation rec {
+  pname = "bpp-popgen";
+
+  inherit (bpp-core) version;
+
+  src = fetchFromGitHub {
+    owner = "BioPP";
+    repo = pname;
+    rev = "v${version}";
+    sha256 = "0bz0fhrq3dri6a0hvfc3zlvrns8mrzzlnicw5pyfa812gc1qwfvh";
+  };
+
+  nativeBuildInputs = [ cmake ];
+  buildInputs = [ bpp-core bpp-seq ];
+
+  postFixup = ''
+    substituteInPlace $out/lib/cmake/${pname}/${pname}-targets.cmake  \
+      --replace 'set(_IMPORT_PREFIX' '#set(_IMPORT_PREFIX'
+  '';
+  # prevents cmake from exporting incorrect INTERFACE_INCLUDE_DIRECTORIES
+  # of form /nix/store/.../nix/store/.../include,
+  # probably due to relative vs absolute path issue
+
+  doCheck = !stdenv.isDarwin;
+
+  meta = bpp-core.meta // {
+    homepage = "https://github.com/BioPP/bpp-popgen";
+    changelog = "https://github.com/BioPP/bpp-popgen/blob/master/ChangeLog";
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/biology/bpp-seq/default.nix b/nixpkgs/pkgs/development/libraries/science/biology/bpp-seq/default.nix
new file mode 100644
index 000000000000..2f6fbf9e362c
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/biology/bpp-seq/default.nix
@@ -0,0 +1,32 @@
+{ stdenv, fetchFromGitHub, cmake, bpp-core }:
+
+stdenv.mkDerivation rec {
+  pname = "bpp-seq";
+
+  inherit (bpp-core) version;
+
+  src = fetchFromGitHub {
+    owner = "BioPP";
+    repo = pname;
+    rev = "v${version}";
+    sha256 = "1mc09g8jswzsa4wgrfv59jxn15ys3q8s0227p1j838wkphlwn2qk";
+  };
+
+  nativeBuildInputs = [ cmake ];
+  buildInputs = [ bpp-core ];
+
+  postFixup = ''
+    substituteInPlace $out/lib/cmake/${pname}/${pname}-targets.cmake  \
+      --replace 'set(_IMPORT_PREFIX' '#set(_IMPORT_PREFIX'
+  '';
+  # prevents cmake from exporting incorrect INTERFACE_INCLUDE_DIRECTORIES
+  # of form /nix/store/.../nix/store/.../include,
+  # probably due to relative vs absolute path issue
+
+  doCheck = !stdenv.isDarwin;
+
+  meta = bpp-core.meta // {
+    homepage = "https://github.com/BioPP/bpp-seq";
+    changelog = "https://github.com/BioPP/bpp-seq/blob/master/ChangeLog";
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/biology/ciftilib/default.nix b/nixpkgs/pkgs/development/libraries/science/biology/ciftilib/default.nix
new file mode 100644
index 000000000000..85b0b1c8a0e5
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/biology/ciftilib/default.nix
@@ -0,0 +1,39 @@
+{ lib
+, stdenv
+, fetchFromGitHub
+, cmake
+, boost
+, libxmlxx
+, pkg-config
+, zlib
+}:
+
+stdenv.mkDerivation rec {
+  pname = "ciftilib";
+  version = "1.6.0";
+
+  src = fetchFromGitHub {
+    owner = "Washington-University";
+    repo = "CiftiLib";
+    rev = "v${version}";
+    hash = "sha256-xc2dpMse4SozYEV/w3rXCrh1LKpTThq5nHB2y5uAD0A=";
+  };
+
+  nativeBuildInputs = [ cmake pkg-config ];
+  buildInputs = [ boost libxmlxx zlib ];
+
+  cmakeFlags = [ "-DCMAKE_CTEST_ARGUMENTS=--exclude-regex;'big|datatype-md5'" ];
+
+  # error: no member named 'file_string' in 'boost::filesystem::path'
+  env.NIX_CFLAGS_COMPILE = "-UCIFTILIB_BOOST_NO_FSV3";
+
+  doCheck = true;
+
+  meta = with lib; {
+    homepage = "https://github.com/Washington-University/CiftiLib";
+    description = "Library for reading and writing CIFTI files";
+    maintainers = with maintainers; [ bcdarwin ];
+    platforms = platforms.unix;
+    license = licenses.bsd2;
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/biology/edlib/default.nix b/nixpkgs/pkgs/development/libraries/science/biology/edlib/default.nix
new file mode 100644
index 000000000000..b8ea4a55291a
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/biology/edlib/default.nix
@@ -0,0 +1,30 @@
+{ lib, stdenv, fetchFromGitHub, cmake }:
+
+stdenv.mkDerivation rec {
+  pname = "edlib";
+  version = "unstable-2021-08-20";
+
+  src = fetchFromGitHub {
+    owner = "Martinsos";
+    repo = pname;
+    rev = "f8afceb49ab0095c852e0b8b488ae2c88e566afd";
+    hash = "sha256-P/tFbvPBtA0MYCNDabW+Ypo3ltwP4S+6lRDxwAZ1JFo=";
+  };
+
+  nativeBuildInputs = [ cmake ];
+
+  doCheck = true;
+  checkPhase = ''
+    runHook preCheck
+    bin/runTests
+    runHook postCheck
+  '';
+
+  meta = with lib; {
+    homepage = "https://martinsos.github.io/edlib";
+    description = "Lightweight, fast C/C++ library for sequence alignment using edit distance";
+    maintainers = with maintainers; [ bcdarwin ];
+    license = licenses.mit;
+    platforms = platforms.unix;
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/biology/elastix/default.nix b/nixpkgs/pkgs/development/libraries/science/biology/elastix/default.nix
new file mode 100644
index 000000000000..0344559f8a8f
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/biology/elastix/default.nix
@@ -0,0 +1,26 @@
+{ lib, stdenv, fetchFromGitHub, cmake, itk, Cocoa }:
+
+stdenv.mkDerivation rec {
+  pname    = "elastix";
+  version = "5.1.0";
+
+  src = fetchFromGitHub {
+    owner = "SuperElastix";
+    repo = pname;
+    rev = version;
+    hash = "sha256-wFeLU8IwiF43a9TAvecQG+QMw88PQZdJ8sI1Zz3ZeXc=";
+  };
+
+  nativeBuildInputs = [ cmake ];
+  buildInputs = [ itk ] ++ lib.optionals stdenv.isDarwin [ Cocoa ];
+
+  doCheck = !stdenv.isDarwin;  # usual dynamic linker issues
+
+  meta = with lib; {
+    homepage = "https://elastix.lumc.nl";
+    description = "Image registration toolkit based on ITK";
+    maintainers = with maintainers; [ bcdarwin ];
+    platforms = platforms.x86_64;  # libitkpng linker issues with ITK 5.1
+    license = licenses.asl20;
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/biology/gifticlib/default.nix b/nixpkgs/pkgs/development/libraries/science/biology/gifticlib/default.nix
new file mode 100644
index 000000000000..306324129cbd
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/biology/gifticlib/default.nix
@@ -0,0 +1,34 @@
+{ lib, stdenv, fetchFromGitHub, cmake, expat, nifticlib, zlib }:
+
+stdenv.mkDerivation rec {
+  pname = "gifticlib";
+  version = "unstable-2020-07-07";
+
+  src = fetchFromGitHub {
+    owner = "NIFTI-Imaging";
+    repo = "gifti_clib";
+    rev = "5eae81ba1e87ef3553df3b6ba585f12dc81a0030";
+    sha256 = "0gcab06gm0irjnlrkpszzd4wr8z0fi7gx8f7966gywdp2jlxzw19";
+  };
+
+  cmakeFlags = [ "-DUSE_SYSTEM_NIFTI=ON" "-DDOWNLOAD_TEST_DATA=OFF" ];
+
+  nativeBuildInputs = [ cmake ];
+  buildInputs = [ expat nifticlib zlib ];
+
+  # without the test data, this is only a few basic tests
+  doCheck = !stdenv.isDarwin;
+  checkPhase = ''
+    runHook preCheck
+    ctest -LE 'NEEDS_DATA'
+    runHook postCheck
+  '';
+
+  meta = with lib; {
+    homepage = "https://www.nitrc.org/projects/gifti";
+    description = "Medical imaging geometry format C API";
+    maintainers = with maintainers; [ bcdarwin ];
+    platforms = platforms.unix;
+    license = licenses.publicDomain;
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/biology/htslib/default.nix b/nixpkgs/pkgs/development/libraries/science/biology/htslib/default.nix
new file mode 100644
index 000000000000..8b1aa7d01e81
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/biology/htslib/default.nix
@@ -0,0 +1,52 @@
+{ lib, stdenv, fetchurl, zlib, bzip2, xz, curl, perl }:
+
+stdenv.mkDerivation rec {
+  pname = "htslib";
+  version = "1.19.1";
+
+  src = fetchurl {
+    url = "https://github.com/samtools/htslib/releases/download/${version}/${pname}-${version}.tar.bz2";
+    sha256 = "sha256-Ii1001dPtnsVjGmIyYDuqrqKBlb15P+3a1+lfwNZM+w=";
+  };
+
+  # perl is only used during the check phase.
+  nativeBuildInputs = [ perl ];
+
+  buildInputs = [ zlib bzip2 xz curl ];
+
+  configureFlags = if ! stdenv.hostPlatform.isStatic
+                    then [ "--enable-libcurl" ] # optional but strongly recommended
+                    else [ "--disable-libcurl" "--disable-plugins" ];
+
+
+  # In the case of static builds, we need to replace the build and install phases
+  buildPhase = lib.optional stdenv.hostPlatform.isStatic ''
+    make AR=$AR lib-static
+    make LDFLAGS=-static bgzip htsfile tabix
+  '';
+
+  installPhase = lib.optional stdenv.hostPlatform.isStatic ''
+    install -d $out/bin
+    install -d $out/lib
+    install -d $out/include/htslib
+    install -D libhts.a $out/lib
+    install  -m644 htslib/*h $out/include/htslib
+    install -D bgzip htsfile tabix $out/bin
+  '';
+
+  preCheck = ''
+    patchShebangs test/
+  '';
+
+  enableParallelBuilding = true;
+
+  doCheck = true;
+
+  meta = with lib; {
+    description = "A C library for reading/writing high-throughput sequencing data";
+    license = licenses.mit;
+    homepage = "http://www.htslib.org/";
+    platforms = platforms.unix;
+    maintainers = [ maintainers.mimame ];
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/biology/mirtk/default.nix b/nixpkgs/pkgs/development/libraries/science/biology/mirtk/default.nix
new file mode 100644
index 000000000000..9af6793ef997
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/biology/mirtk/default.nix
@@ -0,0 +1,72 @@
+{ lib
+, stdenv
+, fetchFromGitHub
+, cmake
+, python3
+, boost
+, eigen
+, libGLU
+, fltk
+, itk
+, vtk
+, zlib
+, tbb
+}:
+
+stdenv.mkDerivation rec {
+  pname = "mirtk";
+  version = "unstable-2022-07-22";
+
+  src = fetchFromGitHub {
+    owner = "BioMedIA";
+    repo = "MIRTK";
+    rev = "973ce2fe3f9508dec68892dbf97cca39067aa3d6";
+    hash = "sha256-vKgkDrbyGOcbaYlxys1duC8ZNG0Y2nqh3TtSQ06Ox0Q=";
+    fetchSubmodules = true;
+  };
+
+  cmakeFlags = [
+    "-DWITH_VTK=ON"
+    "-DBUILD_ALL_MODULES=ON"
+    "-DWITH_TBB=ON"
+    "-DWITH_ITK=ON"
+    "-DWITH_GIFTICLIB=ON"
+    "-DWITH_NIFTILIB=ON"
+  ];
+
+  # tries to download data during configuration
+  postPatch = ''
+    substituteInPlace Packages/DrawEM/CMakeLists.txt --replace "include(Atlases.cmake)" ""
+  '';
+
+  # tests don't seem to be maintained and gtest fails to link with BUILD_TESTING=ON;
+  # unclear if specific to Nixpkgs
+  doCheck = false;
+
+  postInstall = ''
+    install -Dm644 -t "$out/share/bash-completion/completions/mirtk" share/completion/bash/mirtk
+  '';
+
+  env.NIX_CFLAGS_COMPILE = "-Wno-changes-meaning";
+
+  nativeBuildInputs = [ cmake ];
+  buildInputs = [
+    boost
+    eigen
+    fltk
+    itk
+    libGLU.dev
+    python3
+    tbb
+    vtk
+    zlib
+  ];
+
+  meta = with lib; {
+    homepage = "https://github.com/BioMedIA/MIRTK";
+    description = "Medical image registration library and tools";
+    maintainers = with maintainers; [ bcdarwin ];
+    platforms = platforms.linux;
+    license = licenses.asl20;
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/biology/nifticlib/default.nix b/nixpkgs/pkgs/development/libraries/science/biology/nifticlib/default.nix
new file mode 100644
index 000000000000..fee2ea8772b4
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/biology/nifticlib/default.nix
@@ -0,0 +1,33 @@
+{ lib, stdenv, fetchFromGitHub, cmake, zlib }:
+
+stdenv.mkDerivation rec {
+  pname = "nifticlib";
+  version = "3.0.1";
+
+  src = fetchFromGitHub {
+    owner = "NIFTI-Imaging";
+    repo = "nifti_clib";
+    rev = "v${version}";
+    sha256 = "0hamm6nvbjdjjd5md4jahzvn5559frigxaiybnjkh59ckxwb1hy4";
+  };
+
+  cmakeFlags = [ "-DDOWNLOAD_TEST_DATA=OFF" ];
+
+  nativeBuildInputs = [ cmake ];
+  buildInputs = [ zlib ];
+
+  checkPhase = ''
+    runHook preCheck
+    ctest -LE 'NEEDS_DATA'
+    runHook postCheck
+  '';
+  doCheck = true;
+
+  meta = with lib; {
+    homepage = "https://nifti-imaging.github.io";
+    description = "Medical imaging format C API";
+    maintainers = with maintainers; [ bcdarwin ];
+    platforms = platforms.unix;
+    license = licenses.publicDomain;
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/biology/oobicpl/default.nix b/nixpkgs/pkgs/development/libraries/science/biology/oobicpl/default.nix
new file mode 100644
index 000000000000..7f1112311d6b
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/biology/oobicpl/default.nix
@@ -0,0 +1,39 @@
+{ lib
+, stdenv
+, fetchFromGitHub
+, cmake
+, libminc
+, bicpl
+, arguments
+, pcre-cpp }:
+
+stdenv.mkDerivation rec {
+  pname = "oobicpl";
+  version = "unstable-2020-08-12";
+
+  src = fetchFromGitHub {
+    owner  = "BIC-MNI";
+    repo   = pname;
+    rev    = "a9409da8a5bb4925438f32aff577b6333faec28b";
+    sha256 = "0b4chjhr32wbb1sash8cq1jfnr7rzdq84hif8anlrjqd3l0gw357";
+  };
+
+  nativeBuildInputs = [ cmake ];
+
+  buildInputs = [ libminc bicpl arguments pcre-cpp ];
+
+  cmakeFlags = [
+    "-DLIBMINC_DIR=${libminc}/lib/cmake"
+    "-DBICPL_DIR=${bicpl}/lib"
+    "-DARGUMENTS_DIR=${arguments}/lib"
+    "-DOOBICPL_BUILD_SHARED_LIBS=TRUE"
+  ];
+
+  meta = with lib; {
+    homepage = "https://github.com/BIC-MNI/oobicpl";
+    description = "Brain Imaging Centre object-oriented programming library (and tools)";
+    maintainers = with maintainers; [ bcdarwin ];
+    platforms = platforms.unix;
+    license   = licenses.free;
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/chemistry/avogadrolibs/default.nix b/nixpkgs/pkgs/development/libraries/science/chemistry/avogadrolibs/default.nix
new file mode 100644
index 000000000000..e50bde243e85
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/chemistry/avogadrolibs/default.nix
@@ -0,0 +1,89 @@
+{ lib, stdenv, fetchFromGitHub, fetchpatch, cmake, zlib, eigen, libGL, doxygen, spglib
+, mmtf-cpp, glew, python3, libarchive, libmsym, msgpack, qttools, wrapQtAppsHook
+}:
+
+let
+  pythonWP = python3.withPackages (p: with p; [ openbabel-bindings numpy ]);
+
+  # Pure data repositories
+  moleculesRepo = fetchFromGitHub {
+    owner = "OpenChemistry";
+    repo = "molecules";
+    rev = "1.0.0";
+    sha256 = "guY6osnpv7Oqt+HE1BpIqL10POp+x8GAci2kY0bLmqg=";
+  };
+  crystalsRepo = fetchFromGitHub {
+    owner = "OpenChemistry";
+    repo = "crystals";
+    rev = "1.0.1";
+    sha256 = "sH/WuvLaYu6akOc3ssAKhnxD8KNoDxuafDSozHqJZC4=";
+  };
+  fragmentsRepo = fetchFromGitHub {
+    owner = "OpenChemistry";
+    repo = "fragments";
+    rev = "8dc711a59d016604b3e9b6d59dec178b8e6ccd36";
+    hash = "sha256-Valc5zwlaZ//eDupFouCfWCeID7/4ObU1SDLFJ/mo/g=";
+  };
+
+in stdenv.mkDerivation rec {
+  pname = "avogadrolibs";
+  version = "1.99.0";
+
+  src = fetchFromGitHub {
+    owner = "OpenChemistry";
+    repo = pname;
+    rev = version;
+    hash = "sha256-3jUbzEd7tUeHlVFAO9KJ+LOQlkLzJQvwmHp8gOriZRI=";
+  };
+
+  postUnpack = ''
+    cp -r ${moleculesRepo} molecules
+    cp -r ${crystalsRepo} crystals
+    cp -r ${fragmentsRepo} fragments
+  '';
+
+  patches = [
+    # Fix a Cmake error when searching the fragments directory.
+    # Can be removed upon next release
+    (fetchpatch {
+      url = "https://github.com/OpenChemistry/avogadrolibs/commit/6e2e84dbb088a40d69117c1836f4306792f57acd.patch";
+      hash = "sha256-0tY9kHh6e5IDZQ8cWPgTpwIBhfZQlgUEZbPHOmtOVUQ=";
+    })
+  ];
+
+  nativeBuildInputs = [
+    cmake
+    wrapQtAppsHook
+    pythonWP
+  ];
+
+  buildInputs = [
+    eigen
+    zlib
+    libGL
+    spglib
+    mmtf-cpp
+    glew
+    libarchive
+    libmsym
+    msgpack
+    qttools
+  ];
+
+  # Fix the broken CMake files to use the correct paths
+  postInstall = ''
+    substituteInPlace $out/lib/cmake/${pname}/AvogadroLibsConfig.cmake \
+      --replace "$out/" ""
+
+    substituteInPlace $out/lib/cmake/${pname}/AvogadroLibsTargets.cmake \
+      --replace "_IMPORT_PREFIX}/$out" "_IMPORT_PREFIX}/"
+  '';
+
+  meta = with lib; {
+    description = "Molecule editor and visualizer";
+    maintainers = with maintainers; [ sheepforce ];
+    homepage = "https://github.com/OpenChemistry/avogadrolibs";
+    platforms = platforms.linux;
+    license = licenses.gpl2Only;
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/chemistry/avogadrolibs/fragments.patch b/nixpkgs/pkgs/development/libraries/science/chemistry/avogadrolibs/fragments.patch
new file mode 100644
index 000000000000..0f886a8a63a5
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/chemistry/avogadrolibs/fragments.patch
@@ -0,0 +1,13 @@
+diff --git a/avogadro/qtplugins/templatetool/CMakeLists.txt b/avogadro/qtplugins/templatetool/CMakeLists.txt
+index 3f68e6dd..822de4e5 100644
+--- a/avogadro/qtplugins/templatetool/CMakeLists.txt
++++ b/avogadro/qtplugins/templatetool/CMakeLists.txt
+@@ -24,7 +24,7 @@ avogadro_plugin(TemplateTool
+ )
+ 
+ # Install the fragments
+-set(_fragments "${AvogadroLibs_SOURCE_DIR}/../fragments")
++set(_fragments "${AvogadroLibs_SOURCE_DIR}/fragments")
+ 
+ # Look in parallel directory for the molecule fragment repository
+ if(NOT EXISTS "${_fragments}")
diff --git a/nixpkgs/pkgs/development/libraries/science/chemistry/cppe/default.nix b/nixpkgs/pkgs/development/libraries/science/chemistry/cppe/default.nix
new file mode 100644
index 000000000000..9781ce780660
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/chemistry/cppe/default.nix
@@ -0,0 +1,26 @@
+{ stdenv, lib, fetchFromGitHub, cmake, llvmPackages }:
+
+stdenv.mkDerivation rec {
+  pname = "cppe";
+  version = "0.3.1";
+
+  src = fetchFromGitHub {
+    owner = "maxscheurer";
+    repo = pname;
+    rev = "v${version}";
+    sha256 = "sha256-guM7+ZWDJLcAUJtPkKLvC4LYSA2eBvER7cgwPZ7FxHw=";
+  };
+
+  nativeBuildInputs = [ cmake ]
+    ++ lib.optionals stdenv.cc.isClang [ llvmPackages.openmp ];
+
+  cmakeFlags = [ "-DCMAKE_INSTALL_LIBDIR=lib" ];
+
+  meta = with lib; {
+    description = "C++ and Python library for Polarizable Embedding";
+    homepage = "https://github.com/maxscheurer/cppe";
+    license = licenses.lgpl3Only;
+    platforms = platforms.unix;
+    maintainers = [ maintainers.sheepforce ];
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/chemistry/dftd4/default.nix b/nixpkgs/pkgs/development/libraries/science/chemistry/dftd4/default.nix
new file mode 100644
index 000000000000..d791a7d4e3d6
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/chemistry/dftd4/default.nix
@@ -0,0 +1,54 @@
+{ stdenv
+, lib
+, fetchFromGitHub
+, cmake
+, gfortran
+, blas
+, lapack
+, mctc-lib
+, mstore
+, multicharge
+}:
+
+assert !blas.isILP64 && !lapack.isILP64;
+
+stdenv.mkDerivation rec {
+  pname = "dftd4";
+  version = "3.6.0";
+
+  src = fetchFromGitHub {
+    owner = "dftd4";
+    repo = pname;
+    rev = "v${version}";
+    hash = "sha256-VIV9953hx0MZupOARdH+P1h7JtZeJmTlqtO8si+lwdU=";
+  };
+
+  nativeBuildInputs = [ cmake gfortran ];
+
+  buildInputs = [ blas lapack mctc-lib mstore multicharge ];
+
+  outputs = [ "out" "dev" ];
+
+  # Fix the Pkg-Config files for doubled store paths
+  postPatch = ''
+    substituteInPlace config/template.pc \
+      --replace "\''${prefix}/" ""
+  '';
+
+  cmakeFlags = [
+    "-DBUILD_SHARED_LIBS=${if stdenv.hostPlatform.isStatic then "OFF" else "ON"}"
+  ];
+
+  doCheck = true;
+  preCheck = ''
+    export OMP_NUM_THREADS=2
+  '';
+
+  meta = with lib; {
+    description = "Generally Applicable Atomic-Charge Dependent London Dispersion Correction";
+    license = with licenses; [ lgpl3Plus gpl3Plus ];
+    homepage = "https://github.com/grimme-lab/dftd4";
+    platforms = platforms.linux;
+    maintainers = [ maintainers.sheepforce ];
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/chemistry/harminv/default.nix b/nixpkgs/pkgs/development/libraries/science/chemistry/harminv/default.nix
new file mode 100644
index 000000000000..54c0d03979ab
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/chemistry/harminv/default.nix
@@ -0,0 +1,42 @@
+{ lib
+, stdenv
+, fetchFromGitHub
+, autoreconfHook
+, gfortran
+, blas
+, lapack
+}:
+
+assert !blas.isILP64;
+assert !lapack.isILP64;
+
+stdenv.mkDerivation rec {
+  pname = "harminv";
+  version = "1.4.2";
+
+  src = fetchFromGitHub {
+    owner = "NanoComp";
+    repo = pname;
+    rev = "v${version}";
+    hash = "sha256-EXEt7l69etcBdDdEDlD1ODOdhTBZCVjgY1jhRUDd/W0=";
+  };
+
+  # File is missing in the git checkout but required by autotools
+  postPatch = ''
+    touch ChangeLog
+  '';
+
+  nativeBuildInputs = [ autoreconfHook gfortran ];
+
+  buildInputs = [ blas lapack ];
+
+  configureFlags = [ "--enable-shared" ];
+
+  meta = with lib; {
+    description = "Harmonic inversion algorithm of Mandelshtam: decompose signal into sum of decaying sinusoids";
+    homepage = "https://github.com/NanoComp/harminv";
+    license = with licenses; [ gpl2Only ];
+    maintainers = with maintainers; [ sheepforce markuskowa ];
+    platforms = platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/chemistry/libGDSII/default.nix b/nixpkgs/pkgs/development/libraries/science/chemistry/libGDSII/default.nix
new file mode 100644
index 000000000000..c3257bad3e26
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/chemistry/libGDSII/default.nix
@@ -0,0 +1,32 @@
+{ lib
+, stdenv
+, fetchFromGitHub
+, autoreconfHook
+}:
+
+stdenv.mkDerivation rec {
+  pname = "libGDSII";
+  version = "0.21";
+
+  src = fetchFromGitHub {
+    owner = "HomerReid";
+    repo = pname;
+    rev = "v${version}";
+    hash = "sha256-EXEt7l69etcBdDdEDlD1ODOdhTBZCVjgY1jhRUDd/W0=";
+  };
+
+  # File is missing in the repo but automake requires it
+  postPatch = ''
+    touch ChangeLog
+  '';
+
+  nativeBuildInputs = [ autoreconfHook ];
+
+  meta = with lib; {
+    description = "Library and command-line utility for reading GDSII geometry files";
+    homepage = "https://github.com/HomerReid/libGDSII";
+    license = [ licenses.gpl2Only ];
+    maintainers = with maintainers; [ sheepforce markuskowa ];
+    platforms = platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/chemistry/libmsym/default.nix b/nixpkgs/pkgs/development/libraries/science/chemistry/libmsym/default.nix
new file mode 100644
index 000000000000..fdcf7d00e3ba
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/chemistry/libmsym/default.nix
@@ -0,0 +1,23 @@
+{ stdenv, lib, fetchFromGitHub, cmake } :
+
+stdenv.mkDerivation rec {
+  pname = "libmsym";
+  version = "0.2.3";
+
+  src = fetchFromGitHub  {
+    owner = "mcodev31";
+    repo = pname;
+    rev = "v${version}";
+    sha256= "k+OEwrA/saupP/wX6Ii5My0vffiJ0X9xMCTrliMSMik=";
+  };
+
+  nativeBuildInputs = [ cmake ];
+
+  meta = with lib; {
+    description = " molecular point group symmetry lib";
+    homepage = "https://github.com/mcodev31/libmsym";
+    license = licenses.mit;
+    platforms = platforms.linux;
+    maintainers = [ maintainers.sheepforce ];
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/chemistry/libvdwxc/default.nix b/nixpkgs/pkgs/development/libraries/science/chemistry/libvdwxc/default.nix
new file mode 100644
index 000000000000..c0da65e7c788
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/chemistry/libvdwxc/default.nix
@@ -0,0 +1,52 @@
+{ stdenv
+, lib
+, fetchFromGitLab
+, gfortran
+, autoreconfHook
+, fftwMpi
+, mpi
+}:
+
+stdenv.mkDerivation rec {
+  pname = "libvdwxc";
+  # Stable version has non-working MPI detection.
+  version = "unstable-24.02.2020";
+
+  src = fetchFromGitLab {
+    owner = "libvdwxc";
+    repo = pname;
+    rev = "92f4910c6ac88e111db2fb3a518089d0510c53b0";
+    sha256 = "1c7pjrvifncbdyngs2bv185imxbcbq64nka8gshhp8n2ns6fids6";
+  };
+
+  nativeBuildInputs = [ autoreconfHook gfortran ];
+
+  propagatedBuildInputs = [ mpi fftwMpi ];
+
+  preConfigure = ''
+    mkdir build && cd build
+
+    export PATH=$PATH:${mpi}/bin
+    configureFlagsArray+=(
+      --with-mpi=${lib.getDev mpi}
+      CC=mpicc
+      FC=mpif90
+      MPICC=mpicc
+      MPIFC=mpif90
+    )
+  '';
+
+  configureScript = "../configure";
+
+  hardeningDisable = [ "format" ];
+
+  doCheck = true;
+
+  meta = with lib; {
+    description = "Portable C library of density functionals with van der Waals interactions for density functional theory";
+    license = with licenses; [ lgpl3Plus bsd3 ];
+    homepage = "https://libvdwxc.org/";
+    platforms = platforms.unix;
+    maintainers = [ maintainers.sheepforce ];
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/chemistry/mctc-lib/default.nix b/nixpkgs/pkgs/development/libraries/science/chemistry/mctc-lib/default.nix
new file mode 100644
index 000000000000..a3726ea5e5dd
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/chemistry/mctc-lib/default.nix
@@ -0,0 +1,46 @@
+{ stdenv
+, lib
+, fetchFromGitHub
+, gfortran
+, pkg-config
+, json-fortran
+, cmake
+}:
+
+stdenv.mkDerivation rec {
+  pname = "mctc-lib";
+  version = "0.3.1";
+
+  src = fetchFromGitHub {
+    owner = "grimme-lab";
+    repo = pname;
+    rev = "v${version}";
+    hash = "sha256-AXjg/ZsitdDf9fNoGVmVal1iZ4/sxjJb7A9W4yye/rg=";
+  };
+
+  nativeBuildInputs = [ gfortran pkg-config cmake ];
+
+  buildInputs = [ json-fortran ];
+
+  outputs = [ "out" "dev" ];
+
+  # Fix the Pkg-Config files for doubled store paths
+  postPatch = ''
+    substituteInPlace config/template.pc \
+      --replace "\''${prefix}/" ""
+  '';
+
+  cmakeFlags = [
+    "-DBUILD_SHARED_LIBS=${if stdenv.hostPlatform.isStatic then "OFF" else "ON"}"
+  ];
+
+  doCheck = true;
+
+  meta = with lib; {
+    description = "Modular computation tool chain library";
+    homepage = "https://github.com/grimme-lab/mctc-lib";
+    license = licenses.asl20;
+    platforms = platforms.linux;
+    maintainers = [ maintainers.sheepforce ];
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/chemistry/mmtf-cpp/default.nix b/nixpkgs/pkgs/development/libraries/science/chemistry/mmtf-cpp/default.nix
new file mode 100644
index 000000000000..a93b8f32cef2
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/chemistry/mmtf-cpp/default.nix
@@ -0,0 +1,25 @@
+{ stdenv, lib, fetchFromGitHub, cmake, msgpack } :
+
+stdenv.mkDerivation rec {
+  pname = "mmtf-cpp";
+  version = "1.1.0";
+
+  src = fetchFromGitHub  {
+    owner = "rcsb";
+    repo = pname;
+    rev = "v${version}";
+    hash = "sha256-8JrNobvekMggS8L/VORKA32DNUdXiDrYMObjd29wQmc=";
+  };
+
+  nativeBuildInputs = [ cmake ];
+
+  buildInputs = [ msgpack ];
+
+  meta = with lib; {
+    description = "A library of exchange-correlation functionals with arbitrary-order derivatives";
+    homepage = "https://github.com/rcsb/mmtf-cpp";
+    license = licenses.mit;
+    platforms = platforms.linux;
+    maintainers = [ maintainers.sheepforce ];
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/chemistry/molequeue/default.nix b/nixpkgs/pkgs/development/libraries/science/chemistry/molequeue/default.nix
new file mode 100644
index 000000000000..b560ac16c698
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/chemistry/molequeue/default.nix
@@ -0,0 +1,34 @@
+{ lib, stdenv, fetchFromGitHub, cmake, qttools, wrapQtAppsHook }:
+
+stdenv.mkDerivation rec {
+  pname = "molequeue";
+  version = "0.9.0";
+
+  src = fetchFromGitHub {
+    owner = "OpenChemistry";
+    repo = pname;
+    rev = version;
+    hash = "sha256-+NoY8YVseFyBbxc3ttFWiQuHQyy1GN8zvV1jGFjmvLg=";
+  };
+
+  nativeBuildInputs = [
+    cmake
+    wrapQtAppsHook
+  ];
+
+  buildInputs = [ qttools ];
+
+  # Fix the broken CMake files to use the correct paths
+  postInstall = ''
+    substituteInPlace $out/lib/cmake/${pname}/MoleQueueConfig.cmake \
+      --replace "$out/" ""
+  '';
+
+  meta = with lib; {
+    description = "Desktop integration of high performance computing resources";
+    maintainers = with maintainers; [ sheepforce ];
+    homepage = "https://github.com/OpenChemistry/molequeue";
+    platforms = platforms.linux;
+    license = licenses.bsd3;
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/chemistry/mstore/default.nix b/nixpkgs/pkgs/development/libraries/science/chemistry/mstore/default.nix
new file mode 100644
index 000000000000..948d11435461
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/chemistry/mstore/default.nix
@@ -0,0 +1,43 @@
+{ stdenv
+, lib
+, fetchFromGitHub
+, cmake
+, gfortran
+, mctc-lib
+}:
+
+stdenv.mkDerivation rec {
+  pname = "mstore";
+  version = "0.2.0";
+
+  src = fetchFromGitHub {
+    owner = "grimme-lab";
+    repo = pname;
+    rev = "v${version}";
+    hash = "sha256-dN2BulLS/ENRFVdJIrZRxgBV8S4d5+7BjTCGnhBbf4I=";
+  };
+
+  nativeBuildInputs = [ cmake gfortran ];
+
+  buildInputs = [ mctc-lib ];
+
+  outputs = [ "out" "dev" ];
+
+  # Fix the Pkg-Config files for doubled store paths
+  postPatch = ''
+    substituteInPlace config/template.pc \
+      --replace "\''${prefix}/" ""
+  '';
+
+  cmakeFlags = [
+    "-DBUILD_SHARED_LIBS=${if stdenv.hostPlatform.isStatic then "OFF" else "ON"}"
+  ];
+
+  meta = with lib; {
+    description = "Molecular structure store for testing";
+    license = licenses.asl20;
+    homepage = "https://github.com/grimme-lab/mstore";
+    platforms = platforms.linux;
+    maintainers = [ maintainers.sheepforce ];
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/chemistry/multicharge/default.nix b/nixpkgs/pkgs/development/libraries/science/chemistry/multicharge/default.nix
new file mode 100644
index 000000000000..b90f073a4f2e
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/chemistry/multicharge/default.nix
@@ -0,0 +1,53 @@
+{ stdenv
+, lib
+, fetchFromGitHub
+, cmake
+, gfortran
+, blas
+, lapack
+, mctc-lib
+, mstore
+}:
+
+assert !blas.isILP64 && !lapack.isILP64;
+
+stdenv.mkDerivation rec {
+  pname = "multicharge";
+  version = "0.2.0";
+
+  src = fetchFromGitHub {
+    owner = "grimme-lab";
+    repo = pname;
+    rev = "v${version}";
+    hash = "sha256-oUI5x5/Gd0EZBb1w+0jlJUF9X51FnkHFu8H7KctqXl0=";
+  };
+
+  nativeBuildInputs = [ cmake gfortran ];
+
+  buildInputs = [ blas lapack mctc-lib mstore ];
+
+  outputs = [ "out" "dev" ];
+
+  # Fix the Pkg-Config files for doubled store paths
+  postPatch = ''
+    substituteInPlace config/template.pc \
+      --replace "\''${prefix}/" ""
+  '';
+
+  cmakeFlags = [
+    "-DBUILD_SHARED_LIBS=${if stdenv.hostPlatform.isStatic then "OFF" else "ON"}"
+  ];
+
+  doCheck = true;
+  preCheck = ''
+    export OMP_NUM_THREADS=2
+  '';
+
+  meta = with lib; {
+    description = "Electronegativity equilibration model for atomic partial charges";
+    license = licenses.asl20;
+    homepage = "https://github.com/grimme-lab/multicharge";
+    platforms = platforms.linux;
+    maintainers = [ maintainers.sheepforce ];
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/chemistry/openmm/default.nix b/nixpkgs/pkgs/development/libraries/science/chemistry/openmm/default.nix
new file mode 100644
index 000000000000..9b37f14f1403
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/chemistry/openmm/default.nix
@@ -0,0 +1,108 @@
+{ stdenv
+, lib
+, fetchFromGitHub
+, cmake
+, gfortran
+, fftwSinglePrec
+, doxygen
+, swig
+, enablePython ? false
+, python3Packages
+, enableOpencl ? true
+, opencl-headers
+, ocl-icd
+, config
+, enableCuda ? config.cudaSupport
+, cudaPackages
+, addOpenGLRunpath
+}:
+
+stdenv.mkDerivation rec {
+  pname = "openmm";
+  version = "8.1.1";
+
+  src = fetchFromGitHub {
+    owner = "openmm";
+    repo = pname;
+    rev = version;
+    hash = "sha256-pYWBniV1J+UZBOPPjuUxVevONHaclo+GvGBEpr7Zmxg=";
+  };
+
+  # "This test is stochastic and may occassionally fail". It does.
+  postPatch = ''
+    rm \
+      platforms/*/tests/Test*BrownianIntegrator.* \
+      platforms/*/tests/Test*LangevinIntegrator.* \
+      serialization/tests/TestSerializeIntegrator.cpp
+  '';
+
+  nativeBuildInputs = [
+    cmake
+    gfortran
+    swig
+    doxygen
+    python3Packages.python
+  ] ++ lib.optional enableCuda addOpenGLRunpath;
+
+  buildInputs = [ fftwSinglePrec ]
+    ++ lib.optionals enableOpencl [ ocl-icd opencl-headers ]
+    ++ lib.optional enableCuda cudaPackages.cudatoolkit;
+
+  propagatedBuildInputs = lib.optionals enablePython (with python3Packages; [
+    setuptools
+    python
+    numpy
+    cython
+  ]);
+
+  cmakeFlags = [
+    "-DBUILD_TESTING=ON"
+    "-DOPENMM_BUILD_AMOEBA_PLUGIN=ON"
+    "-DOPENMM_BUILD_CPU_LIB=ON"
+    "-DOPENMM_BUILD_C_AND_FORTRAN_WRAPPERS=ON"
+    "-DOPENMM_BUILD_DRUDE_PLUGIN=ON"
+    "-DOPENMM_BUILD_PME_PLUGIN=ON"
+    "-DOPENMM_BUILD_RPMD_PLUGIN=ON"
+    "-DOPENMM_BUILD_SHARED_LIB=ON"
+  ] ++ lib.optionals enablePython [
+    "-DOPENMM_BUILD_PYTHON_WRAPPERS=ON"
+  ] ++ lib.optionals enableOpencl [
+    "-DOPENMM_BUILD_OPENCL_LIB=ON"
+    "-DOPENMM_BUILD_AMOEBA_OPENCL_LIB=ON"
+    "-DOPENMM_BUILD_DRUDE_OPENCL_LIB=ON"
+    "-DOPENMM_BUILD_RPMD_OPENCL_LIB=ON"
+  ] ++ lib.optionals enableCuda [
+    "-DCUDA_SDK_ROOT_DIR=${cudaPackages.cudatoolkit}"
+    "-DOPENMM_BUILD_AMOEBA_CUDA_LIB=ON"
+    "-DOPENMM_BUILD_CUDA_LIB=ON"
+    "-DOPENMM_BUILD_DRUDE_CUDA_LIB=ON"
+    "-DOPENMM_BUILD_RPMD_CUDA_LIB=ON"
+    "-DCMAKE_LIBRARY_PATH=${cudaPackages.cudatoolkit}/lib64/stubs"
+  ];
+
+  postInstall = lib.strings.optionalString enablePython ''
+      export OPENMM_LIB_PATH=$out/lib
+      export OPENMM_INCLUDE_PATH=$out/include
+      cd python
+      ${python3Packages.python.pythonOnBuildForHost.interpreter} setup.py build
+      ${python3Packages.python.pythonOnBuildForHost.interpreter} setup.py install --prefix=$out
+      mv $out/lib/python*/site-packages/OpenMM*.egg/{openmm,simtk} $out/lib/python*/site-packages/.
+    '';
+
+  postFixup = ''
+    for lib in $out/lib/plugins/*CUDA.so $out/lib/plugins/*Cuda*.so; do
+      addOpenGLRunpath "$lib"
+    done
+  '';
+
+  # Couldn't get CUDA to run properly in the sandbox
+  doCheck = !enableCuda && !enableOpencl;
+
+  meta = with lib; {
+    description = "Toolkit for molecular simulation using high performance GPU code";
+    homepage = "https://openmm.org/";
+    license = with licenses; [ gpl3Plus lgpl3Plus mit ];
+    platforms = platforms.linux;
+    maintainers = [ maintainers.sheepforce ];
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/chemistry/plumed/default.nix b/nixpkgs/pkgs/development/libraries/science/chemistry/plumed/default.nix
new file mode 100644
index 000000000000..b825c8270d62
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/chemistry/plumed/default.nix
@@ -0,0 +1,34 @@
+{ stdenv
+, lib
+, fetchFromGitHub
+, blas
+}:
+
+assert !blas.isILP64;
+
+stdenv.mkDerivation rec {
+  pname = "plumed";
+  version = "2.9.0";
+
+  src = fetchFromGitHub {
+    owner = "plumed";
+    repo = "plumed2";
+    rev = "v${version}";
+    hash = "sha256-yL+59f908IhbxGIylI1ydi1BPZwAapjK/vP4/h5gcHk=";
+  };
+
+  postPatch = ''
+    patchShebangs .
+  '';
+
+  buildInputs = [ blas ];
+
+  enableParallelBuilding = true;
+
+  meta = with lib; {
+    description = "Molecular metadynamics library";
+    homepage = "https://github.com/plumed/plumed2";
+    license = licenses.lgpl3Only;
+    maintainers = [ maintainers.sheepforce ];
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/chemistry/simple-dftd3/default.nix b/nixpkgs/pkgs/development/libraries/science/chemistry/simple-dftd3/default.nix
new file mode 100644
index 000000000000..ae5e30d73608
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/chemistry/simple-dftd3/default.nix
@@ -0,0 +1,52 @@
+{ stdenv
+, lib
+, fetchFromGitHub
+, gfortran
+, cmake
+, mctc-lib
+, mstore
+, toml-f
+, blas
+}:
+
+assert !blas.isILP64;
+
+stdenv.mkDerivation rec {
+  pname = "simple-dftd3";
+  version = "1.0.0";
+
+  src = fetchFromGitHub {
+    owner = "dftd3";
+    repo = pname;
+    rev = "v${version}";
+    hash = "sha256-dfXiKKCGJ69aExSKpVC3Bp//COy256R9PDyxCNmDsfo=";
+  };
+
+  nativeBuildInputs = [ cmake gfortran ];
+
+  buildInputs = [ mctc-lib mstore toml-f blas ];
+
+  outputs = [ "out" "dev" ];
+
+  # Fix the Pkg-Config files for doubled store paths
+  postPatch = ''
+    substituteInPlace config/template.pc \
+      --replace "\''${prefix}/" ""
+  '';
+  cmakeFlags = [
+    "-DBUILD_SHARED_LIBS=${if stdenv.hostPlatform.isStatic then "OFF" else "ON"}"
+  ];
+
+  doCheck = true;
+  preCheck = ''
+    export OMP_NUM_THREADS=2
+  '';
+
+  meta = with lib; {
+    description = "Reimplementation of the DFT-D3 program";
+    license = with licenses; [ lgpl3Only gpl3Only ];
+    homepage = "https://github.com/dftd3/simple-dftd3";
+    platforms = [ "x86_64-linux" ];
+    maintainers = [ maintainers.sheepforce ];
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/chemistry/simple-dftd3/python.nix b/nixpkgs/pkgs/development/libraries/science/chemistry/simple-dftd3/python.nix
new file mode 100644
index 000000000000..74f24e10f55f
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/chemistry/simple-dftd3/python.nix
@@ -0,0 +1,42 @@
+{ buildPythonPackage
+, pkg-config
+, meson
+, simple-dftd3
+, cffi
+, numpy
+, toml
+, qcengine
+, pyscf
+, ase
+, pytestCheckHook
+}:
+
+buildPythonPackage {
+  inherit (simple-dftd3) pname version src meta;
+
+  # pytest is also required for installation, not only testing
+  nativeBuildInputs = [ pytestCheckHook ];
+
+  buildInputs = [ simple-dftd3 ];
+
+  propagatedBuildInputs = [
+    cffi
+    numpy
+    toml
+  ];
+
+  checkInputs = [
+    ase
+    qcengine
+    pyscf
+  ];
+
+  preConfigure = ''
+    cd python
+  '';
+
+  # The compiled CFFI is not placed correctly before pytest invocation
+  preCheck = ''
+    find . -name "_libdftd3*" -exec cp {} ./dftd3/. \;
+  '';
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/chemistry/tblite/0001-fix-multicharge-dep-needed-for-static-compilation.patch b/nixpkgs/pkgs/development/libraries/science/chemistry/tblite/0001-fix-multicharge-dep-needed-for-static-compilation.patch
new file mode 100644
index 000000000000..d2d84f42e09f
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/chemistry/tblite/0001-fix-multicharge-dep-needed-for-static-compilation.patch
@@ -0,0 +1,31 @@
+From 1885a2349102742e33c5c97a8ab4bcacc032fc70 Mon Sep 17 00:00:00 2001
+From: Ryan Swart <ryan@talosystems.com>
+Date: Thu, 30 Mar 2023 15:50:23 +0800
+Subject: [PATCH] fix: multicharge dep needed for static compilation
+
+---
+ config/meson.build | 8 ++++++++
+ 1 file changed, 8 insertions(+)
+
+diff --git a/config/meson.build b/config/meson.build
+index 4f76160..629fa5e 100644
+--- a/config/meson.build
++++ b/config/meson.build
+@@ -136,6 +136,14 @@ sdftd3_dep = dependency(
+ )
+ lib_deps += sdftd3_dep
+ 
++# Create multicharge library as subproject
++multicharge_dep = dependency(
++  'multicharge',
++  fallback: ['multicharge'],
++  default_options: ['default_library=static', 'api=false', 'python=false'],
++)
++lib_deps += multicharge_dep
++
+ # Create TOML Fortran as subproject
+ tomlf_dep = dependency(
+   'toml-f',
+-- 
+2.39.2
+
diff --git a/nixpkgs/pkgs/development/libraries/science/chemistry/tblite/default.nix b/nixpkgs/pkgs/development/libraries/science/chemistry/tblite/default.nix
new file mode 100644
index 000000000000..bea5793addbf
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/chemistry/tblite/default.nix
@@ -0,0 +1,75 @@
+{ stdenv
+, lib
+, fetchFromGitHub
+, fetchpatch
+, cmake
+, gfortran
+, blas
+, lapack
+, mctc-lib
+, mstore
+, toml-f
+, multicharge
+, dftd4
+, simple-dftd3
+}:
+
+assert !blas.isILP64 && !lapack.isILP64;
+
+stdenv.mkDerivation rec {
+  pname = "tblite";
+  version = "0.3.0";
+
+  src = fetchFromGitHub {
+    owner = "tblite";
+    repo = pname;
+    rev = "v${version}";
+    hash = "sha256-R7CAFG/x55k5Ieslxeq+DWq1wPip4cI+Yvn1cBbeVNs=";
+  };
+
+  patches = [
+    # toml-f 0.4 compatibility
+    (fetchpatch {
+      url = "https://github.com/tblite/tblite/commit/da759fd02b8fbf470a5c6d3df9657cca6b1d0a9a.diff";
+      hash = "sha256-VaeA2VyK+Eas432HMSpJ0lXxHBBNGpfkUO1eHeWpYl0=";
+    })
+  ];
+
+  # Fix the Pkg-Config files for doubled store paths
+  postPatch = ''
+    substituteInPlace config/template.pc \
+      --replace "\''${prefix}/" ""
+  '';
+
+  nativeBuildInputs = [ cmake gfortran ];
+
+  buildInputs = [
+    blas
+    lapack
+    mctc-lib
+    mstore
+    toml-f
+    multicharge
+    dftd4
+    simple-dftd3
+  ];
+
+  outputs = [ "out" "dev" ];
+
+  cmakeFlags = [
+    "-DBUILD_SHARED_LIBS=${if stdenv.hostPlatform.isStatic then "OFF" else "ON"}"
+  ];
+
+  doCheck = true;
+  preCheck = ''
+    export OMP_NUM_THREADS=2
+  '';
+
+  meta = with lib; {
+    description = "Light-weight tight-binding framework";
+    license = with licenses; [ gpl3Plus lgpl3Plus ];
+    homepage = "https://github.com/tblite/tblite";
+    platforms = platforms.linux;
+    maintainers = [ maintainers.sheepforce ];
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/chemistry/tblite/python.nix b/nixpkgs/pkgs/development/libraries/science/chemistry/tblite/python.nix
new file mode 100644
index 000000000000..3a72cfaaa6a3
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/chemistry/tblite/python.nix
@@ -0,0 +1,61 @@
+{ buildPythonPackage
+, fetchpatch
+, meson
+, ninja
+, pkg-config
+, tblite
+, numpy
+, simple-dftd3
+, cffi
+, gfortran
+, blas
+, lapack
+, mctc-lib
+, mstore
+, toml-f
+, multicharge
+, dftd4
+}:
+
+buildPythonPackage {
+  inherit (tblite) pname version src meta;
+
+  nativeBuildInputs = [
+    tblite
+    meson
+    ninja
+    pkg-config
+    gfortran
+    mctc-lib
+  ];
+
+  buildInputs = [
+    tblite
+    simple-dftd3
+    blas
+    lapack
+    mctc-lib
+    mstore
+    toml-f
+    multicharge
+    dftd4
+  ];
+
+  propagatedBuildInputs = [ tblite simple-dftd3 cffi numpy ];
+
+
+  patches = [
+    # Add multicharge to the meson deps; otherwise we get missing mod_multicharge errors
+    ./0001-fix-multicharge-dep-needed-for-static-compilation.patch
+
+    # Toml-f 0.4.0 compatibility https://github.com/tblite/tblite/pull/108
+    (fetchpatch {
+      url = "https://github.com/tblite/tblite/commit/e4255519b58a5198a5fa8f3073bef1c78a4bbdbe.diff";
+      hash = "sha256-BMwYsdWfK+vG3BFgzusLYfwo0WXrYSPxJoEJIyOvbPg=";
+    })
+  ];
+
+  format = "other";
+  pythonImportsCheck = [ "tblite" "tblite.interface" ];
+  mesonFlags = [ "-Dpython=true" ];
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/chemistry/xcfun/default.nix b/nixpkgs/pkgs/development/libraries/science/chemistry/xcfun/default.nix
new file mode 100644
index 000000000000..0534c7b46b03
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/chemistry/xcfun/default.nix
@@ -0,0 +1,30 @@
+{ stdenv, lib, fetchFromGitHub, cmake, gfortran, python3 } :
+
+stdenv.mkDerivation rec {
+  pname = "xcfun";
+  version = "2.1.1";
+
+  src = fetchFromGitHub  {
+    owner = "dftlibs";
+    repo = pname;
+    rev = "v${version}";
+    sha256 = "1bj70cnhbh6ziy02x988wwl7cbwaq17ld7qwhswqkgnnx8rpgxid";
+  };
+
+  nativeBuildInputs = [
+    cmake
+    gfortran
+  ];
+
+  propagatedBuildInputs = [ (python3.withPackages (p: with p; [ pybind11 ])) ];
+
+  cmakeFlags = [ "-DXCFUN_MAX_ORDER=3" ];
+
+  meta = with lib; {
+    description = "A library of exchange-correlation functionals with arbitrary-order derivatives";
+    homepage = "https://github.com/dftlibs/xcfun";
+    license = licenses.mpl20;
+    platforms = platforms.unix;
+    maintainers = [ maintainers.sheepforce ];
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/electronics/coloquinte/default.nix b/nixpkgs/pkgs/development/libraries/science/electronics/coloquinte/default.nix
new file mode 100644
index 000000000000..6946080c100e
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/electronics/coloquinte/default.nix
@@ -0,0 +1,38 @@
+{ lib
+, stdenv
+, fetchFromGitHub
+, cmake
+, lemon-graph
+, eigen
+, boost
+}:
+
+stdenv.mkDerivation (finalAttrs: {
+  pname = "coloquinte";
+  version = "0.3.1";
+
+  src = fetchFromGitHub {
+    owner = "coloquinte";
+    repo = "PlaceRoute";
+    rev = finalAttrs.version;
+    hash = "sha256-bPDXaNZCNBM0qiu+46cL/zH/41lwqHPqfqTzJaERgVQ=";
+  };
+
+  nativeBuildInputs = [
+    cmake
+  ];
+
+  buildInputs = [
+    lemon-graph
+    eigen
+    boost
+  ];
+
+  meta = {
+    description = "Placement library for electronic circuits";
+    homepage = "https://github.com/Coloquinte/PlaceRoute";
+    license = lib.licenses.mit;
+    platforms = lib.platforms.linux;
+    maintainers = [ lib.maintainers.coloquinte ];
+  };
+})
diff --git a/nixpkgs/pkgs/development/libraries/science/electronics/qcsxcad/default.nix b/nixpkgs/pkgs/development/libraries/science/electronics/qcsxcad/default.nix
new file mode 100644
index 000000000000..6ac453aec2c0
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/electronics/qcsxcad/default.nix
@@ -0,0 +1,47 @@
+{ lib
+, mkDerivation
+, fetchFromGitHub
+, cmake
+, csxcad
+, tinyxml
+, vtkWithQt5
+, qtbase
+}:
+
+mkDerivation {
+  pname = "qcsxcad";
+  version = "unstable-2023-01-06";
+
+  src = fetchFromGitHub {
+    owner = "thliebig";
+    repo = "QCSXCAD";
+    rev = "1cde9d560a5000f4c24c249d2dd5ccda12de38b6";
+    hash = "sha256-kc9Vnx6jGiQC2K88ZH00b61D/DbWxAIZZwYCsINqtrY=";
+  };
+
+  outputs = [ "out" "dev" ];
+
+  nativeBuildInputs = [
+    cmake
+  ];
+
+  cmakeFlags = [
+    "-DCSXCAD_ROOT_DIR=${csxcad}"
+    "-DENABLE_RPATH=OFF"
+  ];
+
+  buildInputs = [
+    csxcad
+    tinyxml
+    vtkWithQt5
+    qtbase
+  ];
+
+  meta = with lib; {
+    description = "Qt library for CSXCAD";
+    homepage = "https://github.com/thliebig/QCSXCAD";
+    license = licenses.gpl3;
+    maintainers = with maintainers; [ matthuszagh ];
+    platforms = platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/math/QuadProgpp/default.nix b/nixpkgs/pkgs/development/libraries/science/math/QuadProgpp/default.nix
new file mode 100644
index 000000000000..f67d68d768a0
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/math/QuadProgpp/default.nix
@@ -0,0 +1,33 @@
+{ lib
+, stdenv
+, fetchFromGitHub
+, cmake
+}:
+
+stdenv.mkDerivation {
+  pname = "quadprogpp";
+  version = "unstable-2023-01-20";
+
+  src = fetchFromGitHub {
+    owner = "liuq";
+    repo = "QuadProgpp";
+    rev = "4c51d91deb5af251957edf9454bfb74279a4544e";
+    hash = "sha256-uozwuTAOPsRwYM9KyG3V0hwcmaPpfZPID9Wdd4olsvY=";
+  };
+
+  nativeBuildInputs = [
+    cmake
+  ];
+
+  meta = with lib; {
+    description = "A C++ library for Quadratic Programming";
+    longDescription = ''
+      QuadProg++ is a C++ library for Quadratic Programming which implements
+      the Goldfarb-Idnani active-set dual method.
+    '';
+    homepage = "https://github.com/liuq/QuadProgpp";
+    license = licenses.mit;
+    maintainers = with maintainers; [ wegank ];
+    platforms = platforms.all;
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/math/amd-blis/default.nix b/nixpkgs/pkgs/development/libraries/science/math/amd-blis/default.nix
new file mode 100644
index 000000000000..17838ab37390
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/math/amd-blis/default.nix
@@ -0,0 +1,72 @@
+{ lib, stdenv
+, fetchFromGitHub
+, perl
+, python3
+
+# Enable BLAS interface with 64-bit integer width.
+, blas64 ? false
+
+# Target architecture. "amdzen" compiles kernels for all Zen
+# generations. To build kernels for specific Zen generations,
+# use "zen", "zen2", "zen3", or "zen4".
+, withArchitecture ? "amdzen"
+
+# Enable OpenMP-based threading.
+, withOpenMP ? true
+}:
+
+let
+  threadingSuffix = lib.optionalString withOpenMP "-mt";
+  blasIntSize = if blas64 then "64" else "32";
+
+in stdenv.mkDerivation rec {
+  pname = "amd-blis";
+  version = "4.2";
+
+  src = fetchFromGitHub {
+    owner = "amd";
+    repo = "blis";
+    rev = version;
+    hash = "sha256-mLigzaA2S7qFCQT8UWC6bHWAvBjgpqvtgabPyFWBYT0=";
+  };
+
+  inherit blas64;
+
+  nativeBuildInputs = [
+    perl
+    python3
+  ];
+
+  # Tests currently fail with non-Zen CPUs due to a floating point
+  # exception in one of the generic kernels. Try to re-enable the
+  # next release.
+  doCheck = false;
+
+  enableParallelBuilding = true;
+
+  configureFlags = [
+    "--enable-cblas"
+    "--blas-int-size=${blasIntSize}"
+  ] ++ lib.optionals withOpenMP [ "--enable-threading=openmp" ]
+    ++ [ withArchitecture ];
+
+  postPatch = ''
+    patchShebangs configure build/flatten-headers.py
+  '';
+
+  postInstall = ''
+    ls $out/lib
+    ln -s $out/lib/libblis${threadingSuffix}.so $out/lib/libblas.so.3
+    ln -s $out/lib/libblis${threadingSuffix}.so $out/lib/libcblas.so.3
+    ln -s $out/lib/libblas.so.3 $out/lib/libblas.so
+    ln -s $out/lib/libcblas.so.3 $out/lib/libcblas.so
+  '';
+
+  meta = with lib; {
+    description = "BLAS-compatible library optimized for AMD CPUs";
+    homepage = "https://developer.amd.com/amd-aocl/blas-library/";
+    license = licenses.bsd3;
+    maintainers = [ maintainers.markuskowa ];
+    platforms = [ "x86_64-linux" ];
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/math/amd-libflame/default.nix b/nixpkgs/pkgs/development/libraries/science/math/amd-libflame/default.nix
new file mode 100644
index 000000000000..0ca1c4950541
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/math/amd-libflame/default.nix
@@ -0,0 +1,62 @@
+{ lib
+, stdenv
+, fetchFromGitHub
+, cmake
+, gfortran
+, python3
+, amd-blis
+, aocl-utils
+
+, withOpenMP ? true
+, blas64 ? false
+, withAMDOpt ? true
+}:
+
+stdenv.mkDerivation rec {
+  pname = "amd-libflame";
+  version = "4.2";
+
+  src = fetchFromGitHub {
+    owner = "amd";
+    repo = "libflame";
+    rev = version;
+    hash = "sha256-eiH2eq+nKUjlB1bZTZNRW1+efCHZ68UOSFy0NpcY1FI=";
+  };
+
+  postPatch = ''
+    patchShebangs build
+
+    # Enforce reproducible build compiler flags
+    substituteInPlace CMakeLists.txt --replace '-mtune=native' ""
+  '';
+
+  passthru = { inherit blas64; };
+
+  nativeBuildInputs = [ cmake gfortran python3 ];
+
+  buildInputs = [ amd-blis aocl-utils ];
+
+  cmakeFlags = [
+    "-DLIBAOCLUTILS_LIBRARY_PATH=${lib.getLib aocl-utils}/lib/libaoclutils${stdenv.hostPlatform.extensions.sharedLibrary}"
+    "-DLIBAOCLUTILS_INCLUDE_PATH=${lib.getDev aocl-utils}/include"
+    "-DENABLE_BUILTIN_LAPACK2FLAME=ON"
+    "-DENABLE_CBLAS_INTERFACES=ON"
+    "-DENABLE_EXT_LAPACK_INTERFACE=ON"
+  ]
+  ++ lib.optional (!withOpenMP) "-DENABLE_MULTITHREADING=OFF"
+  ++ lib.optional blas64 "-DENABLE_ILP64=ON"
+  ++ lib.optional withAMDOpt "-DENABLE_AMD_OPT=ON";
+
+  postInstall = ''
+    ln -s $out/lib/libflame.so $out/lib/liblapack.so.3
+    ln -s $out/lib/libflame.so $out/lib/liblapacke.so.3
+  '';
+
+  meta = with lib; {
+    description = "LAPACK-compatible linear algebra library optimized for AMD CPUs";
+    homepage = "https://developer.amd.com/amd-aocl/blas-library/";
+    license = licenses.bsd3;
+    maintainers = [ maintainers.markuskowa ];
+    platforms = [ "x86_64-linux" ];
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/math/arpack/default.nix b/nixpkgs/pkgs/development/libraries/science/math/arpack/default.nix
new file mode 100644
index 000000000000..744d565eddcd
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/math/arpack/default.nix
@@ -0,0 +1,68 @@
+{ lib, stdenv, fetchFromGitHub, cmake
+, gfortran, blas, lapack, eigen
+, useMpi ? false
+, mpi
+, openssh
+, igraph
+}:
+
+# MPI version can only be built with LP64 interface.
+# See https://github.com/opencollab/arpack-ng#readme
+assert useMpi -> !blas.isILP64;
+
+stdenv.mkDerivation rec {
+  pname = "arpack";
+  version = "3.9.1";
+
+  src = fetchFromGitHub {
+    owner = "opencollab";
+    repo = "arpack-ng";
+    rev = version;
+    sha256 = "sha256-HCvapLba8oLqx9I5+KDAU0s/dTmdWOEilS75i4gyfC0=";
+  };
+
+  nativeBuildInputs = [ cmake gfortran ];
+  buildInputs = assert (blas.isILP64 == lapack.isILP64); [
+    blas
+    lapack
+    eigen
+  ] ++ lib.optional useMpi mpi;
+
+  nativeCheckInputs = lib.optional useMpi openssh;
+
+  doCheck = true;
+
+  cmakeFlags = [
+    "-DBUILD_SHARED_LIBS=ON"
+    "-DINTERFACE64=${if blas.isILP64 then "1" else "0"}"
+    "-DMPI=${if useMpi then "ON" else "OFF"}"
+  ];
+
+  preCheck = ''
+    # Prevent tests from using all cores
+    export OMP_NUM_THREADS=2
+  '';
+
+  postFixup = lib.optionalString stdenv.isDarwin ''
+    install_name_tool -change libblas.dylib ${blas}/lib/libblas.dylib $out/lib/libarpack.dylib
+  '';
+
+  passthru = {
+    inherit (blas) isILP64;
+    tests = {
+      inherit igraph;
+    };
+  };
+
+  meta = {
+    homepage = "https://github.com/opencollab/arpack-ng";
+    changelog = "https://github.com/opencollab/arpack-ng/blob/${src.rev}/CHANGES";
+    description = ''
+      A collection of Fortran77 subroutines to solve large scale eigenvalue
+      problems.
+    '';
+    license = lib.licenses.bsd3;
+    maintainers = with lib.maintainers; [ ttuegel dotlambda ];
+    platforms = lib.platforms.unix;
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/math/blas/default.nix b/nixpkgs/pkgs/development/libraries/science/math/blas/default.nix
new file mode 100644
index 000000000000..4431ab63c7b7
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/math/blas/default.nix
@@ -0,0 +1,44 @@
+{ lib, stdenv, fetchurl, cmake, gfortran
+# Whether to build with ILP64 interface
+, blas64 ? false
+}:
+
+stdenv.mkDerivation rec {
+  pname = "blas";
+  version = "3.12.0";
+
+  src = fetchurl {
+    url = "http://www.netlib.org/blas/${pname}-${version}.tgz";
+    sha256 = "sha256-zMQbXQiOUNsAMDF66bDJrzdXEME5KsrR/iCWAtpaWq0=";
+  };
+
+  passthru = { inherit blas64; };
+
+  nativeBuildInputs = [ cmake gfortran ];
+
+  cmakeFlags = [ "-DBUILD_SHARED_LIBS=ON" ]
+    ++ lib.optional blas64 "-DBUILD_INDEX64=ON";
+
+  postInstall = let
+    canonicalExtension = if stdenv.hostPlatform.isLinux
+                       then "${stdenv.hostPlatform.extensions.sharedLibrary}.${lib.versions.major version}"
+                       else stdenv.hostPlatform.extensions.sharedLibrary;
+  in lib.optionalString blas64 ''
+    ln -s $out/lib/libblas64${canonicalExtension} $out/lib/libblas${canonicalExtension}
+  '';
+
+  preFixup = lib.optionalString stdenv.isDarwin ''
+    for fn in $(find $out/lib -name "*.so*"); do
+      if [ -L "$fn" ]; then continue; fi
+      install_name_tool -id "$fn" "$fn"
+    done
+  '';
+
+  meta = with lib; {
+    description = "Basic Linear Algebra Subprograms";
+    license = licenses.publicDomain;
+    maintainers = [ maintainers.markuskowa ];
+    homepage = "http://www.netlib.org/blas/";
+    platforms = platforms.unix;
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/math/blis/default.nix b/nixpkgs/pkgs/development/libraries/science/math/blis/default.nix
new file mode 100644
index 000000000000..2c9aa745ba12
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/math/blis/default.nix
@@ -0,0 +1,64 @@
+{ lib, stdenv
+, fetchFromGitHub
+, perl
+, python3
+
+# Enable BLAS interface with 64-bit integer width.
+, blas64 ? false
+
+# Target architecture. x86_64 builds Intel and AMD kernels.
+, withArchitecture ? "x86_64"
+
+# Enable OpenMP-based threading.
+, withOpenMP ? true
+}:
+
+let
+  blasIntSize = if blas64 then "64" else "32";
+in stdenv.mkDerivation rec {
+  pname = "blis";
+  version = "0.9.0";
+
+  src = fetchFromGitHub {
+    owner = "flame";
+    repo = "blis";
+    rev = version;
+    sha256 = "sha256-1aHIdt5wCDrT1hBPnaUVThwjwDkJQ0G0+tao2iFXYpM=";
+  };
+
+  inherit blas64;
+
+  nativeBuildInputs = [
+    perl
+    python3
+  ];
+
+  doCheck = true;
+
+  enableParallelBuilding = true;
+
+  configureFlags = [
+    "--enable-cblas"
+    "--blas-int-size=${blasIntSize}"
+  ] ++ lib.optionals withOpenMP [ "--enable-threading=openmp" ]
+    ++ [ withArchitecture ];
+
+  postPatch = ''
+    patchShebangs configure build/flatten-headers.py
+  '';
+
+  postInstall = ''
+    ln -s $out/lib/libblis.so.4 $out/lib/libblas.so.3
+    ln -s $out/lib/libblis.so.4 $out/lib/libcblas.so.3
+    ln -s $out/lib/libblas.so.3 $out/lib/libblas.so
+    ln -s $out/lib/libcblas.so.3 $out/lib/libcblas.so
+  '';
+
+  meta = with lib; {
+    description = "BLAS-compatible linear algebra library";
+    homepage = "https://github.com/flame/blis";
+    license = licenses.bsd3;
+    maintainers = [ ];
+    platforms = [ "x86_64-linux" ];
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/math/bonmin/default.nix b/nixpkgs/pkgs/development/libraries/science/math/bonmin/default.nix
new file mode 100644
index 000000000000..5a736f976957
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/math/bonmin/default.nix
@@ -0,0 +1,53 @@
+{ lib
+, stdenv
+, fetchFromGitHub
+, gfortran
+, pkg-config
+, blas
+, bzip2
+, cbc
+, clp
+, ipopt
+, lapack
+, libamplsolver
+, zlib
+}:
+
+assert (!blas.isILP64) && (!lapack.isILP64);
+
+stdenv.mkDerivation rec {
+  pname = "bonmin";
+  version = "1.8.9";
+
+  src = fetchFromGitHub {
+    owner = "coin-or";
+    repo = "Bonmin";
+    rev = "releases/${version}";
+    sha256 = "sha256-nqjAQ1NdNJ/T4p8YljEWRt/uy2aDwyBeAsag0TmRc5Q=";
+  };
+
+  nativeBuildInputs = [
+    gfortran
+    pkg-config
+  ];
+  buildInputs = [
+    blas
+    bzip2
+    cbc
+    clp
+    ipopt
+    lapack
+    libamplsolver
+    zlib
+  ];
+
+  meta = with lib; {
+    description = "An open-source code for solving general MINLP (Mixed Integer NonLinear Programming) problems";
+    homepage = "https://github.com/coin-or/Bonmin";
+    license = licenses.epl10;
+    platforms = platforms.unix;
+    maintainers = with maintainers; [ aanderse ];
+    # never built on aarch64-darwin, x86_64-darwin since first introduction in nixpkgs
+    broken = stdenv.isDarwin;
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/math/brial/default.nix b/nixpkgs/pkgs/development/libraries/science/math/brial/default.nix
new file mode 100644
index 000000000000..6ec28ba1c226
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/math/brial/default.nix
@@ -0,0 +1,46 @@
+{ lib, stdenv
+, fetchFromGitHub
+, autoreconfHook
+, pkg-config
+, boost
+, m4ri
+, gd
+}:
+
+stdenv.mkDerivation rec {
+  version = "1.2.12";
+  pname = "brial";
+
+  src = fetchFromGitHub {
+    owner = "BRiAl";
+    repo = "BRiAl";
+    rev = version;
+    sha256 = "sha256-y6nlqRBJRWohGDAKe/F37qBP1SgtFHR1HD+erFJReOM=";
+  };
+
+  # FIXME package boost-test and enable checks
+  doCheck = false;
+
+  configureFlags = [
+    "--with-boost-unit-test-framework=no"
+  ];
+
+  buildInputs = [
+    boost
+    m4ri
+    gd
+  ];
+
+  nativeBuildInputs = [
+    autoreconfHook
+    pkg-config
+  ];
+
+  meta = with lib; {
+    homepage = "https://github.com/BRiAl/BRiAl";
+    description = "Legacy version of PolyBoRi maintained by sagemath developers";
+    license = licenses.gpl2Plus;
+    maintainers = teams.sage.members;
+    platforms = platforms.unix;
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/math/cholmod-extra/default.nix b/nixpkgs/pkgs/development/libraries/science/math/cholmod-extra/default.nix
new file mode 100644
index 000000000000..311ffefcfaad
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/math/cholmod-extra/default.nix
@@ -0,0 +1,35 @@
+{ lib, stdenv, fetchFromGitHub, gfortran, suitesparse, blas, lapack }:
+stdenv.mkDerivation rec {
+  pname = "cholmod-extra";
+  version = "1.2.0";
+
+  src = fetchFromGitHub {
+    repo = pname;
+    owner = "jluttine";
+    rev = version;
+    sha256 = "0hz1lfp0zaarvl0dv0zgp337hyd8np41kmdpz5rr3fc6yzw7vmkg";
+  };
+
+  nativeBuildInputs = [ gfortran ];
+  buildInputs = [ suitesparse blas lapack ];
+
+  makeFlags = [
+    "BLAS=-lcblas"
+  ];
+
+  installFlags = [
+    "INSTALL_LIB=$(out)/lib"
+    "INSTALL_INCLUDE=$(out)/include"
+  ];
+
+  doCheck = true;
+
+  meta = with lib; {
+    homepage = "https://github.com/jluttine/cholmod-extra";
+    description = "A set of additional routines for SuiteSparse CHOLMOD Module";
+    license = with licenses; [ gpl2Plus ];
+    maintainers = with maintainers; [ jluttine ];
+    platforms = with platforms; unix;
+  };
+
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/math/clblas/default.nix b/nixpkgs/pkgs/development/libraries/science/math/clblas/default.nix
new file mode 100644
index 000000000000..a87d107b3a17
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/math/clblas/default.nix
@@ -0,0 +1,68 @@
+{ lib, stdenv
+, fetchFromGitHub
+, cmake
+, gfortran
+, blas
+, boost
+, python3
+, ocl-icd
+, opencl-headers
+, Accelerate, CoreGraphics, CoreVideo, OpenCL
+}:
+
+stdenv.mkDerivation rec {
+  pname = "clblas";
+  version = "2.12";
+
+  src = fetchFromGitHub {
+    owner = "clMathLibraries";
+    repo = "clBLAS";
+    rev = "v${version}";
+    sha256 = "154mz52r5hm0jrp5fqrirzzbki14c1jkacj75flplnykbl36ibjs";
+  };
+
+  patches = [ ./platform.patch ];
+
+  postPatch = ''
+    sed -i -re 's/(set\(\s*Boost_USE_STATIC_LIBS\s+).*/\1OFF\ \)/g' src/CMakeLists.txt
+  '';
+
+  preConfigure = ''
+    cd src
+  '';
+
+  cmakeFlags = [
+     "-DBUILD_TEST=OFF"
+  ];
+
+  nativeBuildInputs = [ cmake gfortran ];
+  buildInputs = [
+    blas
+    python3
+    boost
+  ] ++ lib.optionals (!stdenv.isDarwin) [
+    ocl-icd
+    opencl-headers
+  ] ++ lib.optionals stdenv.isDarwin [
+    Accelerate
+    CoreGraphics
+    CoreVideo
+  ];
+  propagatedBuildInputs = lib.optionals stdenv.isDarwin [
+    OpenCL
+  ];
+
+  strictDeps = true;
+
+  meta = with lib; {
+    homepage = "https://github.com/clMathLibraries/clBLAS";
+    description = "A software library containing BLAS functions written in OpenCL";
+    longDescription = ''
+      This package contains a library of BLAS functions on top of OpenCL.
+    '';
+    license = licenses.asl20;
+    maintainers = with maintainers; [ artuuge ];
+    platforms = platforms.unix;
+  };
+
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/math/clblas/platform.patch b/nixpkgs/pkgs/development/libraries/science/math/clblas/platform.patch
new file mode 100644
index 000000000000..87404a426a4b
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/math/clblas/platform.patch
@@ -0,0 +1,34 @@
+diff --git a/src/library/tools/ktest/config.cpp b/src/library/tools/ktest/config.cpp
+index 8b20128..faf9bde 100644
+--- a/src/library/tools/ktest/config.cpp
++++ b/src/library/tools/ktest/config.cpp
+@@ -24,8 +24,6 @@
+ 
+ using namespace clMath;
+ 
+-static const char DEFAULT_PLATFORM_NAME[] = "AMD Accelerated Parallel Processing";
+-
+ Config::Config() :
+     defaultConfig_(""),
+     cpp_("ktest.cpp"),
+@@ -35,7 +33,10 @@ Config::Config() :
+     hasFuncID_(false), hasSubdims_(false),
+     skipAccuracy_(false)
+ {
+-    setPlatform(DEFAULT_PLATFORM_NAME);
++    platform_ = NULL;
++    setPlatform("");
++
++    device_ = NULL;
+     setDevice("");
+ 
+     memset(&kargs_, 0, sizeof(kargs_));
+@@ -262,7 +263,7 @@ Config::setPlatform(const std::string& name)
+             continue;
+         }
+         if (name.empty()) {
+-            found = (strcmp(pname, DEFAULT_PLATFORM_NAME) == 0);
++	    found = true;
+         }
+         else {
+             found = (strcmp(pname, name.c_str()) == 0);
diff --git a/nixpkgs/pkgs/development/libraries/science/math/clblast/default.nix b/nixpkgs/pkgs/development/libraries/science/math/clblast/default.nix
new file mode 100644
index 000000000000..e4bbd09a7586
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/math/clblast/default.nix
@@ -0,0 +1,44 @@
+{ lib
+, stdenv
+, fetchFromGitHub
+, cmake
+, ninja
+, opencl-headers
+, ocl-icd
+}:
+
+stdenv.mkDerivation rec {
+  pname = "clblast";
+  version = "1.6.2";
+
+  src = fetchFromGitHub {
+    owner = "CNugteren";
+    repo = "CLBlast";
+    rev = version;
+    hash = "sha256-S25g25Il6rzkpU9IqOFDDeEr3uYyt/uewZZAl09YSts=";
+  };
+
+  nativeBuildInputs = [
+    cmake
+    ninja
+  ];
+
+  buildInputs = [
+    opencl-headers
+    ocl-icd
+  ];
+
+  cmakeFlags = [
+    # https://github.com/NixOS/nixpkgs/issues/144170
+    "-DCMAKE_INSTALL_INCLUDEDIR=include"
+    "-DCMAKE_INSTALL_LIBDIR=lib"
+  ];
+
+  meta = with lib; {
+    description = "The tuned OpenCL BLAS library";
+    homepage = "https://github.com/CNugteren/CLBlast";
+    license = licenses.asl20;
+    maintainers = with maintainers; [ Tungsten842 ];
+    platforms = platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/math/cliquer/default.nix b/nixpkgs/pkgs/development/libraries/science/math/cliquer/default.nix
new file mode 100644
index 000000000000..55a1b9dcb4c9
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/math/cliquer/default.nix
@@ -0,0 +1,39 @@
+{ lib, stdenv
+, fetchFromGitHub
+, autoreconfHook
+}:
+
+stdenv.mkDerivation rec {
+  version = "1.22";
+  pname = "cliquer";
+
+  # autotoolized version of the original cliquer
+  src = fetchFromGitHub {
+    owner = "dimpase";
+    repo = "autocliquer";
+    rev = "v${version}";
+    sha256 = "00gcmrhi2fjn8b246w5a3b0pl7p6haxy5wjvd9kcqib1xanz59z4";
+  };
+
+  doCheck = true;
+
+  nativeBuildInputs = [
+    autoreconfHook
+  ];
+
+  meta = with lib; {
+    description = "Routines for clique searching";
+    longDescription = ''
+      Cliquer is a set of C routines for finding cliques in an arbitrary weighted graph.
+      It uses an exact branch-and-bound algorithm developed by Patric Östergård.
+      It is designed with the aim of being efficient while still being flexible and
+      easy to use.
+    '';
+    homepage = "https://users.aalto.fi/~pat/cliquer.html";
+    downloadPage = src.meta.homepage; # autocliquer
+    license = licenses.gpl2Plus;
+    maintainers = teams.sage.members;
+    mainProgram = "cl";
+    platforms = platforms.unix;
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/math/clmagma/default.nix b/nixpkgs/pkgs/development/libraries/science/math/clmagma/default.nix
new file mode 100644
index 000000000000..c5efbb757df8
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/math/clmagma/default.nix
@@ -0,0 +1,73 @@
+{ lib, stdenv, fetchurl, gfortran, opencl-headers, clblas, ocl-icd, mkl, intel-ocl }:
+
+let
+  incfile = builtins.toFile "make.inc.custom" ''
+    CC        = g++
+    FORT      = gfortran
+
+    ARCH      = ar
+    ARCHFLAGS = cr
+    RANLIB    = ranlib
+
+    OPTS      = -fPIC -O3 -DADD_ -Wall
+    FOPTS     = -fPIC -O3 -DADD_ -Wall -x f95-cpp-input
+    F77OPTS   = -fPIC -O3 -DADD_ -Wall
+    LDOPTS    = -fPIC
+
+    -include make.check-mkl
+    -include make.check-clblas
+
+    # Gnu mkl is not available I guess?
+    #LIB       = -lmkl_gf_lp64 -lmkl_gnu_thread -lmkl_core -lpthread -lm -fopenmp
+    LIB        = -lmkl_intel_lp64 -lmkl_intel_thread -lmkl_core -liomp5 -lm -fopenmp
+    LIB       += -lclBLAS -lOpenCL
+
+    LIBDIR    = -L$(MKLROOT)/lib/intel64 \
+                -L$(MKLROOT)/../compiler/lib/intel64 \
+                -L$(clBLAS)/lib64
+
+    INC       = -I$(clBLAS)/include
+               #-I$(AMDAPP)/include
+  '';
+in stdenv.mkDerivation rec {
+  pname = "clmagma";
+  version = "1.3.0";
+  src = fetchurl {
+    url = "https://icl.cs.utk.edu/projectsfiles/magma/cl/clmagma-${version}.tar.gz";
+    sha256 = "1n27ny0xhwirw2ydn46pfcwy53gzia9zbam4irx44fd4d7f9ydv7";
+    name = "clmagma-${version}.tar.gz";
+  };
+
+  buildInputs = [
+    gfortran
+    clblas
+    opencl-headers
+    ocl-icd
+    mkl
+    intel-ocl
+  ];
+
+  enableParallelBuilding=true;
+
+  MKLROOT   = "${mkl}";
+  clBLAS    = "${clblas}";
+
+  # Otherwise build looks for it in /run/opengl-driver/etc/OpenCL/vendors,
+  # which is not available.
+  OPENCL_VENDOR_PATH="${intel-ocl}/etc/OpenCL/vendors";
+
+  preBuild = ''
+    # By default it tries to use GPU, and thus fails for CPUs
+    sed -i "s/CL_DEVICE_TYPE_GPU/CL_DEVICE_TYPE_DEFAULT/" interface_opencl/clmagma_runtime.cpp
+    sed -i "s%/usr/local/clmagma%/$out%" Makefile.internal
+    cp ${incfile} make.inc
+  '';
+
+  meta = with lib; {
+    description = "Matrix Algebra on GPU and Multicore Architectures, OpenCL port";
+    license = licenses.bsd3;
+    homepage = "https://icl.cs.utk.edu/magma/index.html";
+    platforms = platforms.linux;
+    maintainers = with maintainers; [ volhovm ];
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/math/coin-utils/default.nix b/nixpkgs/pkgs/development/libraries/science/math/coin-utils/default.nix
new file mode 100644
index 000000000000..60b9de0ab33a
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/math/coin-utils/default.nix
@@ -0,0 +1,31 @@
+{ lib, stdenv, fetchFromGitHub, fetchpatch }:
+
+stdenv.mkDerivation rec {
+  version = "2.11.10";
+  pname = "coinutils";
+
+  src = fetchFromGitHub {
+    owner = "coin-or";
+    repo = "CoinUtils";
+    rev = "releases/${version}";
+    hash = "sha256-Rbm45HRbRKQ6Cdup+gvKJ1xkK1HKG3irR5AIjhLer7g=";
+  };
+
+  patches = [
+    (fetchpatch {
+      url = "https://github.com/coin-or/CoinUtils/commit/1700ed92c2bc1562aabe65dee3b4885bd5c87fb9.patch";
+      stripLen = 1;
+      extraPrefix = "CoinUtils/";
+      hash = "sha256-8S6XteZvoJlL+5MWiOrW7HXsdcnzpuEFTyzX9qg7OUY=";
+    })
+  ];
+
+  doCheck = true;
+
+  meta = with lib; {
+    license = licenses.epl20;
+    homepage = "https://github.com/coin-or/CoinUtils";
+    description = "Collection of classes and helper functions that are generally useful to multiple COIN-OR projects";
+    maintainers = with maintainers; [ tmarkus ];
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/math/dbcsr/default.nix b/nixpkgs/pkgs/development/libraries/science/math/dbcsr/default.nix
new file mode 100644
index 000000000000..2c576a190026
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/math/dbcsr/default.nix
@@ -0,0 +1,81 @@
+{ stdenv
+, lib
+, fetchFromGitHub
+, cmake
+, mpiCheckPhaseHook
+, pkg-config
+, fypp
+, gfortran
+, blas
+, lapack
+, python3
+, libxsmm
+, mpi
+, openssh
+}:
+
+stdenv.mkDerivation rec {
+  pname = "dbcsr";
+  version = "2.6.0";
+
+  src = fetchFromGitHub {
+    owner = "cp2k";
+    repo = "dbcsr";
+    rev = "v${version}";
+    hash = "sha256-+xSxfrzsxBdb424F/3mIETleEPoETxU0LB0OBJrR7gw=";
+  };
+
+  postPatch = ''
+    patchShebangs .
+
+    # Force build of shared library, otherwise just static.
+    substituteInPlace src/CMakeLists.txt \
+      --replace 'add_library(dbcsr ''${DBCSR_SRCS})' 'add_library(dbcsr SHARED ''${DBCSR_SRCS})' \
+      --replace 'add_library(dbcsr_c ''${DBCSR_C_SRCS})' 'add_library(dbcsr_c SHARED ''${DBCSR_C_SRCS})'
+
+    # Avoid calling the fypp wrapper script with python again. The nix wrapper took care of that.
+    substituteInPlace cmake/fypp-sources.cmake \
+      --replace 'COMMAND ''${Python_EXECUTABLE} ''${FYPP_EXECUTABLE}' 'COMMAND ''${FYPP_EXECUTABLE}'
+  '';
+
+  nativeBuildInputs = [
+    gfortran
+    python3
+    cmake
+    pkg-config
+    fypp
+  ];
+
+  buildInputs = [ blas lapack libxsmm ];
+
+  propagatedBuildInputs = [ mpi ];
+
+  preConfigure = ''
+    export PKG_CONFIG_PATH=${libxsmm}/lib
+  '';
+
+  cmakeFlags = [
+    "-DUSE_OPENMP=ON"
+    "-DUSE_SMM=libxsmm"
+    "-DWITH_C_API=ON"
+    "-DBUILD_TESTING=ON"
+    "-DTEST_OMP_THREADS=2"
+    "-DTEST_MPI_RANKS=2"
+    "-DENABLE_SHARED=ON"
+    "-DUSE_MPI=ON"
+  ];
+
+  checkInputs = [
+    openssh
+    mpiCheckPhaseHook
+  ];
+
+  doCheck = true;
+
+  meta = with lib; {
+    description = "Distributed Block Compressed Sparse Row matrix library";
+    license = licenses.gpl2Only;
+    homepage = "https://github.com/cp2k/dbcsr";
+    maintainers = [ maintainers.sheepforce ];
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/math/ecos/default.nix b/nixpkgs/pkgs/development/libraries/science/math/ecos/default.nix
new file mode 100644
index 000000000000..b60bd1fe76c1
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/math/ecos/default.nix
@@ -0,0 +1,38 @@
+{ lib, stdenv, fetchFromGitHub }:
+
+stdenv.mkDerivation rec {
+  pname = "ecos";
+  version = "2.0.7";
+
+  src = fetchFromGitHub {
+    owner = "embotech";
+    repo = "ecos";
+    rev = version;
+    sha256 = "1hsndim5kjvcwk5svqa4igawzahj982180xj1d7yd0dbjlgxc7w7";
+  };
+
+  buildPhase = ''
+    make all shared
+  '';
+
+  doCheck = true;
+  checkPhase = ''
+    make test
+    ./runecos
+  '';
+
+  installPhase = ''
+    mkdir -p $out/lib
+    cp lib*.a lib*.so $out/lib
+    cp -r include $out/
+  '';
+
+  meta = with lib; {
+    description = "A lightweight conic solver for second-order cone programming";
+    homepage = "https://www.embotech.com/ECOS";
+    downloadPage = "https://github.com/embotech/ecos/releases";
+    license = licenses.gpl3;
+    platforms = platforms.all;
+    maintainers = with maintainers; [ bhipple ];
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/math/faiss/default.nix b/nixpkgs/pkgs/development/libraries/science/math/faiss/default.nix
new file mode 100644
index 000000000000..25ac539e05f2
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/math/faiss/default.nix
@@ -0,0 +1,153 @@
+{ 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
+}@inputs:
+
+let
+  pname = "faiss";
+  version = "1.7.4";
+
+  inherit (cudaPackages) cudaFlags backendStdenv;
+  inherit (cudaFlags) cudaCapabilities dropDot;
+
+  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
+    ];
+  };
+in
+stdenv.mkDerivation {
+  inherit pname version;
+
+  outputs = [ "out" "demos" ];
+
+  src = fetchFromGitHub {
+    owner = "facebookresearch";
+    repo = pname;
+    rev = "v${version}";
+    hash = "sha256-WSce9X6sLZmGM5F0ZkK54VqpIy8u1VB0e9/l78co29M=";
+  };
+
+  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
+  ];
+
+  passthru.extra-requires.all = [
+    pythonPackages.numpy
+  ];
+
+  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=${builtins.concatStringsSep ";" (map dropDot cudaCapabilities)}"
+    "-DCUDAToolkit_INCLUDE_DIR=${cudaJoined}/include"
+  ];
+
+
+  # pip wheel->pip install commands copied over from opencv4
+
+  buildPhase = ''
+    make -j faiss
+    make demo_ivfpq_indexing
+  '' + lib.optionalString pythonSupport ''
+    make -j swigfaiss
+    (cd faiss/python &&
+     python -m pip wheel --verbose --no-index --no-deps --no-clean --no-build-isolation --wheel-dir dist .)
+  '';
+
+  installPhase = ''
+    make install
+    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)
+  '';
+
+  fixupPhase = lib.optionalString (pythonSupport && cudaSupport) ''
+    addOpenGLRunpath $out/${pythonPackages.python.sitePackages}/faiss/*.so
+    addOpenGLRunpath $demos/bin/*
+  '';
+
+  # Need buildPythonPackage for this one
+  # pythonImportsCheck = [
+  #   "faiss"
+  # ];
+
+  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 { };
+    };
+  };
+
+  meta = with lib; {
+    description = "A library for efficient similarity search and clustering of dense vectors by Facebook Research";
+    homepage = "https://github.com/facebookresearch/faiss";
+    license = licenses.mit;
+    platforms = platforms.unix;
+    maintainers = with maintainers; [ SomeoneSerge ];
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/math/faiss/tests.nix b/nixpkgs/pkgs/development/libraries/science/math/faiss/tests.nix
new file mode 100644
index 000000000000..858a980bfeaf
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/math/faiss/tests.nix
@@ -0,0 +1,37 @@
+{ 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/nixpkgs/pkgs/development/libraries/science/math/flintqs/default.nix b/nixpkgs/pkgs/development/libraries/science/math/flintqs/default.nix
new file mode 100644
index 000000000000..c5426ed67fc7
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/math/flintqs/default.nix
@@ -0,0 +1,40 @@
+{ lib, stdenv
+, fetchFromGitHub
+, autoreconfHook
+, gmp
+}:
+
+stdenv.mkDerivation rec {
+  version = "1.0";
+  pname = "flintqs";
+
+  src = fetchFromGitHub {
+    owner = "sagemath";
+    repo = "FlintQS";
+    rev = "v${version}";
+    sha256 = "1f0lnayz6j6qgasx8pbq61d2fqam0wwhsmh6h15l4vq58l1vvbwj";
+  };
+
+  preAutoreconf = ''
+    touch ChangeLog
+  '';
+
+  buildInputs = [
+    gmp
+  ];
+
+  nativeBuildInputs = [
+    autoreconfHook
+  ];
+
+  doCheck = true;
+
+  meta = with lib; {
+    description = "Highly optimized multi-polynomial quadratic sieve for integer factorization";
+    homepage = "https://github.com/sagemath/FlintQS";
+    license = with licenses; [ gpl2 ];
+    maintainers = teams.sage.members;
+    mainProgram = "QuadraticSieve";
+    platforms = platforms.all;
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/math/ipopt/default.nix b/nixpkgs/pkgs/development/libraries/science/math/ipopt/default.nix
new file mode 100644
index 000000000000..a76c2f878ba7
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/math/ipopt/default.nix
@@ -0,0 +1,43 @@
+{ lib
+, stdenv
+, fetchFromGitHub
+, pkg-config
+, blas
+, lapack
+, gfortran
+, enableAMPL ? true, libamplsolver
+}:
+
+assert (!blas.isILP64) && (!lapack.isILP64);
+
+stdenv.mkDerivation rec {
+  pname = "ipopt";
+  version = "3.14.14";
+
+  src = fetchFromGitHub {
+    owner = "coin-or";
+    repo = "Ipopt";
+    rev = "releases/${version}";
+    sha256 = "sha256-qMPdJVLIXFePhTA6qRr1Pth/BjJ62cj9y8C1HKQJGDQ=";
+  };
+
+  CXXDEFS = [ "-DHAVE_RAND" "-DHAVE_CSTRING" "-DHAVE_CSTDIO" ];
+
+  configureFlags = [
+    "--with-asl-cflags=-I${libamplsolver}/include"
+    "--with-asl-lflags=-lamplsolver"
+  ];
+
+  nativeBuildInputs = [ pkg-config gfortran ];
+  buildInputs = [ blas lapack ] ++ lib.optionals enableAMPL [ libamplsolver ];
+
+  enableParallelBuilding = true;
+
+  meta = with lib; {
+    description = "A software package for large-scale nonlinear optimization";
+    homepage = "https://projects.coin-or.org/Ipopt";
+    license = licenses.epl10;
+    platforms = platforms.unix;
+    maintainers = with maintainers; [ abbradar ];
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/math/itpp/default.nix b/nixpkgs/pkgs/development/libraries/science/math/itpp/default.nix
new file mode 100644
index 000000000000..639497bb1f8c
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/math/itpp/default.nix
@@ -0,0 +1,53 @@
+{ lib, stdenv
+, fetchurl
+, cmake
+, gtest
+, blas
+, fftw
+, liblapack
+, gfortran
+}:
+
+stdenv.mkDerivation rec {
+  pname = "it++";
+  version = "4.3.1";
+
+  src = fetchurl {
+    url = "mirror://sourceforge/itpp/itpp-${version}.tar.bz2";
+    sha256 = "0xxqag9wi0lg78xgw7b40rp6wxqp5grqlbs9z0ifvdfzqlhpcwah";
+  };
+
+  nativeBuildInputs = [ cmake gfortran ];
+  buildInputs = [
+    fftw
+    liblapack
+
+    # NOTE: OpenBLAS doesn't work here because IT++ doesn't pass aligned
+    # buffers, which causes segfaults in the optimized kernels :-(
+    blas
+  ];
+
+  cmakeFlags = [
+    "-DCMAKE_CXX_FLAGS=-std=c++14"
+    "-DBLAS_FOUND:BOOL=TRUE"
+    "-DBLAS_LIBRARIES:STRING=${blas}/lib/libblas.so"
+    "-DLAPACK_FOUND:BOOL=TRUE"
+    "-DLAPACK_LIBRARIES:STRING=${liblapack}/lib/liblapack.so"
+    "-DGTEST_DIR:PATH=${gtest.src}/googletest"
+  ];
+
+  doCheck = true;
+
+  checkPhase = ''
+    ./gtests/itpp_gtests
+  '';
+
+  meta = with lib; {
+    description = "IT++ is a C++ library of mathematical, signal processing and communication classes and functions";
+    homepage = "https://itpp.sourceforge.net/";
+    license = licenses.gpl3;
+    platforms = platforms.unix;
+    maintainers = with maintainers; [ andrew-d ];
+    broken = stdenv.isDarwin; # never built on Hydra https://hydra.nixos.org/job/nixpkgs/trunk/itpp.x86_64-darwin
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/math/latte-integrale/default.nix b/nixpkgs/pkgs/development/libraries/science/math/latte-integrale/default.nix
new file mode 100644
index 000000000000..7eb485974ff2
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/math/latte-integrale/default.nix
@@ -0,0 +1,41 @@
+{ lib
+, stdenv
+, fetchurl
+, fetchpatch
+, gmp
+, ntl
+, cddlib
+}:
+
+stdenv.mkDerivation (finalAttrs: {
+  pname = "latte-integrale";
+  version = "1.7.6";
+
+  src = fetchurl {
+    url = "https://github.com/latte-int/latte/releases/download/version_${lib.replaceStrings ["."] ["_"] finalAttrs.version}/latte-int-${finalAttrs.version}.tar.gz";
+    sha256 = "sha256-AGwQ6+XVv9ybFZy6YmSkQyhh/nY84F/oIWJKt9P8IXA=";
+  };
+
+  patches = [
+    # C++17 compat
+    (fetchpatch {
+      url = "https://github.com/latte-int/latte/commit/6dbf7f07d5c9e1f3afe793f782d191d4465088ae.patch";
+      excludes = [ "code/latte/sqlite/IntegrationDB.h" ];
+      sha256 = "sha256-i7c11y54OLuJ0m7PBnhEoAzJzxC842JU7A6TOtTz06k=";
+    })
+  ];
+
+  buildInputs = [
+    gmp
+    ntl
+    cddlib
+  ];
+
+  meta = {
+    description = "Software for counting lattice points and integration over convex polytopes";
+    homepage = "https://www.math.ucdavis.edu/~latte/";
+    license = lib.licenses.gpl2;
+    maintainers = with lib.maintainers; [ amesgen ];
+    platforms = lib.platforms.unix;
+  };
+})
diff --git a/nixpkgs/pkgs/development/libraries/science/math/lcalc/default.nix b/nixpkgs/pkgs/development/libraries/science/math/lcalc/default.nix
new file mode 100644
index 000000000000..b1896917658c
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/math/lcalc/default.nix
@@ -0,0 +1,41 @@
+{ lib, stdenv
+, autoreconfHook
+, gengetopt
+, pkg-config
+, fetchFromGitLab
+, pari
+}:
+
+stdenv.mkDerivation rec {
+  version = "2.0.5";
+  pname = "lcalc";
+
+  src = fetchFromGitLab {
+    owner = "sagemath";
+    repo = pname;
+    rev = version;
+    sha256 = "sha256-RxWZ7T0I9zV7jUVnL6jV/PxEoU32KY7Q1UsOL5Lonuc=";
+  };
+
+  nativeBuildInputs = [
+    autoreconfHook
+    gengetopt
+    pkg-config
+  ];
+
+  buildInputs = [
+    pari
+  ];
+
+  configureFlags = [
+    "--with-pari"
+  ];
+
+  meta = with lib; {
+    homepage = "https://gitlab.com/sagemath/lcalc";
+    description = "A program for calculating with L-functions";
+    license = with licenses; [ gpl2 ];
+    maintainers = teams.sage.members;
+    platforms = platforms.all;
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/math/libamplsolver/default.nix b/nixpkgs/pkgs/development/libraries/science/math/libamplsolver/default.nix
new file mode 100644
index 000000000000..a40091bac8b5
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/math/libamplsolver/default.nix
@@ -0,0 +1,39 @@
+{ lib, stdenv, substitute, fetchurl, fetchpatch }:
+
+stdenv.mkDerivation rec {
+  pname = "libamplsolver";
+  version = "20211109";
+
+  src = fetchurl {
+    url = "https://ampl.com/netlib/ampl/solvers.tgz";
+    sha256 = "sha256-LVmScuIvxmZzywPSBl9T9YcUBJP7UFAa3eWs9r4q3JM=";
+  };
+
+  patches = [
+    (substitute {
+      src = ./libamplsolver-sharedlib.patch;
+      substitutions = [ "--replace" "@sharedlibext@" "${stdenv.hostPlatform.extensions.sharedLibrary}" ];
+    })
+  ];
+
+  installPhase = ''
+    runHook preInstall
+    pushd sys.$(uname -m).$(uname -s)
+    install -D -m 0644 *.h -t $out/include
+    install -D -m 0644 *${stdenv.hostPlatform.extensions.sharedLibrary}* -t $out/lib
+    install -D -m 0644 *.a -t $out/lib
+    popd
+  '' + lib.optionalString stdenv.isDarwin ''
+    install_name_tool -id $out/lib/libamplsolver.dylib $out/lib/libamplsolver.dylib
+  '' + ''
+    runHook postInstall
+  '';
+
+  meta = with lib; {
+    description = "A library of routines that help solvers work with AMPL";
+    homepage = "https://ampl.com/netlib/ampl/";
+    license = [ licenses.mit ];
+    platforms = platforms.unix;
+    maintainers = with maintainers; [ aanderse ];
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/math/libamplsolver/libamplsolver-sharedlib.patch b/nixpkgs/pkgs/development/libraries/science/math/libamplsolver/libamplsolver-sharedlib.patch
new file mode 100644
index 000000000000..f2af2910e89c
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/math/libamplsolver/libamplsolver-sharedlib.patch
@@ -0,0 +1,39 @@
+Authors: Andrei Rozanski and Grace Dinh
+Last-Update: 2022-08-23
+Description: fix makefile.u in order to get libamplsover.so (Linux) or libamplsolver.dylib (Mac)
+
+--- a/makefile.u
++++ b/makefile.u
+
+@@ -26,8 +26,9 @@
+
+ .SUFFIXES: .c .o
+ CC = cc
+-CFLAGS = -O
++CFLAGS := $(CFLAGS) -pipe -DASL_BUILD -fPIC -DPIC
+ SHELL=/bin/sh
++OFILES=$(addsuffix .o,$(basename $(a)))
+
+ # Add -DNO_RUSAGE to the CFLAGS assignment if your system
+ # lacks getrusage().  This only matters for compiling xectim.c.
+@@ -86,7 +87,7 @@
+ .c.o:
+ 	$(CC) -c $(CFLAGS) $*.c
+
+-all: arith.h stdio1.h amplsolver.a funcadd0.o
++all: arith.h stdio1.h amplsolver.a funcadd0.o libamplsolver@sharedlibext@
+
+ a = \
+ 	asldate.c \
+@@ -189,6 +190,11 @@
+ # search path, e.g.
+ #	exec true
+ # or just comment out the ranlib invocation above.
++libamplsolver.so: $(OFILES)
++	$(CC) $^ -shared  -Wl,-soname,libamplsolver.so.0 $(LDFLAGS) -o $@.0
++	ln -s $@.0 $@
++libamplsolver.dylib: amplsolver.a
++	$(CC) -fpic -shared -Wl,-all_load amplsolver.a $(LDFLAGS) -o libamplsolver.dylib
+
+ Aslh = arith.h asl.h funcadd.h stdio1.h
+ auxinfo.o libnamsave.o: funcadd.h stdio1.h
\ No newline at end of file
diff --git a/nixpkgs/pkgs/development/libraries/science/math/libbraiding/default.nix b/nixpkgs/pkgs/development/libraries/science/math/libbraiding/default.nix
new file mode 100644
index 000000000000..2ee2e831f6e6
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/math/libbraiding/default.nix
@@ -0,0 +1,34 @@
+{ lib, stdenv
+, fetchFromGitHub
+, autoreconfHook
+}:
+
+stdenv.mkDerivation rec {
+  version = "1.2";
+  pname = "libbraiding";
+
+  src = fetchFromGitHub {
+    owner = "miguelmarco";
+    repo = "libbraiding";
+    rev = version;
+    sha256 = "sha256-cgg6rvlOvFqGjgbw6i7QXS+tqvfFd1MkPCEjnW/FyFs=";
+  };
+
+  nativeBuildInputs = [
+    autoreconfHook
+  ];
+
+  # no tests included for now (2018-08-05), but can't hurt to activate
+  doCheck = true;
+
+  meta = with lib; {
+    homepage = "https://github.com/miguelmarco/libbraiding/";
+    description = "C++ library for computations on braid groups";
+    longDescription = ''
+      A library to compute several properties of braids, including centralizer and conjugacy check.
+    '';
+    license = licenses.gpl3;
+    maintainers = teams.sage.members;
+    platforms = platforms.all;
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/math/libhomfly/default.nix b/nixpkgs/pkgs/development/libraries/science/math/libhomfly/default.nix
new file mode 100644
index 000000000000..d0f09290c3c7
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/math/libhomfly/default.nix
@@ -0,0 +1,35 @@
+{ lib, stdenv
+, fetchFromGitHub
+, autoreconfHook
+, boehmgc
+}:
+
+stdenv.mkDerivation rec {
+  version = "1.02r6";
+  pname = "libhomfly";
+
+  src = fetchFromGitHub {
+    owner = "miguelmarco";
+    repo = "libhomfly";
+    rev = version;
+    sha256 = "sha256-s1Hgy6S9+uREKsgjOVQdQfnds6oSLo5UWTrt5DJnY2s=";
+  };
+
+  buildInputs = [
+    boehmgc
+  ];
+
+  nativeBuildInputs = [
+    autoreconfHook
+  ];
+
+  doCheck = true;
+
+  meta = with lib; {
+    homepage = "https://github.com/miguelmarco/libhomfly/";
+    description = "Library to compute the homfly polynomial of knots and links";
+    license = licenses.unlicense;
+    maintainers = teams.sage.members;
+    platforms = platforms.all;
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/math/liblapack/default.nix b/nixpkgs/pkgs/development/libraries/science/math/liblapack/default.nix
new file mode 100644
index 000000000000..595ba2aa5713
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/math/liblapack/default.nix
@@ -0,0 +1,83 @@
+{ lib
+, stdenv
+, fetchFromGitHub
+, gfortran
+, cmake
+, shared ? true
+# Compile with ILP64 interface
+, blas64 ? false
+, testers
+}:
+
+stdenv.mkDerivation (finalAttrs: {
+  pname = "liblapack";
+  version = "3.12.0";
+
+  src = fetchFromGitHub {
+    owner = "Reference-LAPACK";
+    repo = "lapack";
+    rev = "v${finalAttrs.version}";
+    sha256 = "sha256-xn9HL4YF8JPka1gwet5bGGo2k505H3RfWpxkUIYNecQ=";
+  };
+
+  nativeBuildInputs = [ gfortran cmake ];
+
+  # Configure stage fails on aarch64-darwin otherwise, due to either clang 11 or gfortran 10.
+  hardeningDisable = lib.optionals (stdenv.isDarwin && stdenv.isAarch64) [ "stackprotector" ];
+
+  cmakeFlags = [
+    "-DCMAKE_Fortran_FLAGS=-fPIC"
+    "-DLAPACKE=ON"
+    "-DCBLAS=ON"
+    "-DBUILD_TESTING=ON"
+  ] ++ lib.optional shared "-DBUILD_SHARED_LIBS=ON"
+    ++ lib.optional blas64 "-DBUILD_INDEX64=ON"
+    # Tries to run host platform binaries during the build
+    # Will likely be disabled by default in 3.12, see:
+    # https://github.com/Reference-LAPACK/lapack/issues/757
+    ++ lib.optional (!stdenv.buildPlatform.canExecute stdenv.hostPlatform) "-DTEST_FORTRAN_COMPILER=OFF";
+
+  passthru = { inherit blas64; };
+
+  postInstall =  let
+    canonicalExtension = if stdenv.hostPlatform.isLinux
+                       then "${stdenv.hostPlatform.extensions.sharedLibrary}.${lib.versions.major finalAttrs.version}"
+                       else stdenv.hostPlatform.extensions.sharedLibrary;
+  in lib.optionalString blas64 ''
+    ln -s $out/lib/liblapack64${canonicalExtension} $out/lib/liblapack${canonicalExtension}
+    ln -s $out/lib/liblapacke64${canonicalExtension} $out/lib/liblapacke${canonicalExtension}
+  '';
+
+  doCheck = true;
+
+  # Some CBLAS related tests fail on Darwin:
+  #  14 - CBLAS-xscblat2 (Failed)
+  #  15 - CBLAS-xscblat3 (Failed)
+  #  17 - CBLAS-xdcblat2 (Failed)
+  #  18 - CBLAS-xdcblat3 (Failed)
+  #  20 - CBLAS-xccblat2 (Failed)
+  #  21 - CBLAS-xccblat3 (Failed)
+  #  23 - CBLAS-xzcblat2 (Failed)
+  #  24 - CBLAS-xzcblat3 (Failed)
+  #
+  # Upstream issue to track:
+  # * https://github.com/Reference-LAPACK/lapack/issues/440
+  ctestArgs = lib.optionalString stdenv.isDarwin "-E '^(CBLAS-(x[sdcz]cblat[23]))$'";
+
+  checkPhase = ''
+    runHook preCheck
+    ctest ${finalAttrs.ctestArgs}
+    runHook postCheck
+  '';
+
+  passthru.tests.pkg-config = testers.testMetaPkgConfig finalAttrs.finalPackage;
+
+  meta = with lib; {
+    description = "Linear Algebra PACKage";
+    homepage = "http://www.netlib.org/lapack/";
+    maintainers = with maintainers; [ markuskowa ];
+    license = licenses.bsd3;
+    pkgConfigModules = [ "lapack" ];
+    platforms = platforms.all;
+  };
+})
diff --git a/nixpkgs/pkgs/development/libraries/science/math/liblbfgs/default.nix b/nixpkgs/pkgs/development/libraries/science/math/liblbfgs/default.nix
new file mode 100644
index 000000000000..26a1932bd192
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/math/liblbfgs/default.nix
@@ -0,0 +1,19 @@
+{ lib, stdenv, fetchurl }:
+stdenv.mkDerivation rec {
+  pname = "liblbfgs";
+  version = "1.10";
+
+  configureFlags = [ "--enable-sse2" ];
+  src = fetchurl {
+    url = "https://github.com/downloads/chokkan/liblbfgs/liblbfgs-${version}.tar.gz";
+    sha256 = "1kv8d289rbz38wrpswx5dkhr2yh4fg4h6sszkp3fawxm09sann21";
+  };
+
+  meta = {
+    broken = (stdenv.isLinux && stdenv.isAarch64);
+    description = "Library of Limited-memory Broyden-Fletcher-Goldfarb-Shanno (L-BFGS)";
+    homepage = "http://www.chokkan.org/software/liblbfgs/";
+    license = lib.licenses.mit;
+    platforms = lib.platforms.unix;
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/math/libtorch/bin.nix b/nixpkgs/pkgs/development/libraries/science/math/libtorch/bin.nix
new file mode 100644
index 000000000000..47a6249ebdc6
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/math/libtorch/bin.nix
@@ -0,0 +1,104 @@
+{ callPackage
+, stdenv
+, fetchzip
+, lib
+, libcxx
+
+, addOpenGLRunpath
+, patchelf
+, fixDarwinDylibNames
+
+, cudaSupport
+}:
+
+let
+  # The binary libtorch distribution statically links the CUDA
+  # toolkit. This means that we do not need to provide CUDA to
+  # this derivation. However, we should ensure on version bumps
+  # that the CUDA toolkit for `passthru.tests` is still
+  # up-to-date.
+  version = "2.0.0";
+  device = if cudaSupport then "cuda" else "cpu";
+  srcs = import ./binary-hashes.nix version;
+  unavailable = throw "libtorch is not available for this platform";
+  libcxx-for-libtorch = if stdenv.hostPlatform.system == "x86_64-darwin" then libcxx else stdenv.cc.cc.lib;
+in stdenv.mkDerivation {
+  inherit version;
+  pname = "libtorch";
+
+  src = fetchzip srcs."${stdenv.hostPlatform.system}-${device}" or unavailable;
+
+  nativeBuildInputs =
+    if stdenv.isDarwin then [ fixDarwinDylibNames ]
+    else [ patchelf ] ++ lib.optionals cudaSupport [ addOpenGLRunpath ];
+
+  dontBuild = true;
+  dontConfigure = true;
+  dontStrip = true;
+
+  installPhase = ''
+    # Copy headers and CMake files.
+    mkdir -p $dev
+    cp -r include $dev
+    cp -r share $dev
+
+    install -Dm755 -t $out/lib lib/*${stdenv.hostPlatform.extensions.sharedLibrary}*
+
+    # We do not care about Java support...
+    rm -f $out/lib/lib*jni* 2> /dev/null || true
+
+    # Fix up library paths for split outputs
+    substituteInPlace $dev/share/cmake/Torch/TorchConfig.cmake \
+      --replace \''${TORCH_INSTALL_PREFIX}/lib "$out/lib" \
+
+    substituteInPlace \
+      $dev/share/cmake/Caffe2/Caffe2Targets-release.cmake \
+      --replace \''${_IMPORT_PREFIX}/lib "$out/lib" \
+  '';
+
+  postFixup = let
+    rpath = lib.makeLibraryPath [ stdenv.cc.cc.lib ];
+  in lib.optionalString stdenv.isLinux ''
+    find $out/lib -type f \( -name '*.so' -or -name '*.so.*' \) | while read lib; do
+      echo "setting rpath for $lib..."
+      patchelf --set-rpath "${rpath}:$out/lib" "$lib"
+      ${lib.optionalString cudaSupport ''
+        addOpenGLRunpath "$lib"
+      ''}
+    done
+  '' + lib.optionalString stdenv.isDarwin ''
+    for f in $out/lib/*.dylib; do
+        otool -L $f
+    done
+    for f in $out/lib/*.dylib; do
+      install_name_tool -id $out/lib/$(basename $f) $f || true
+      for rpath in $(otool -L $f | grep rpath | awk '{print $1}');do
+        install_name_tool -change $rpath $out/lib/$(basename $rpath) $f
+      done
+      if otool -L $f | grep /usr/lib/libc++ >& /dev/null; then
+        install_name_tool -change /usr/lib/libc++.1.dylib ${libcxx-for-libtorch.outPath}/lib/libc++.1.0.dylib $f
+      fi
+    done
+    for f in $out/lib/*.dylib; do
+        otool -L $f
+    done
+  '';
+
+  outputs = [ "out" "dev" ];
+
+  passthru.tests.cmake = callPackage ./test {
+    inherit cudaSupport;
+  };
+
+  meta = with lib; {
+    description = "C++ API of the PyTorch machine learning framework";
+    homepage = "https://pytorch.org/";
+    sourceProvenance = with sourceTypes; [ binaryNativeCode ];
+    # Includes CUDA and Intel MKL, but redistributions of the binary are not limited.
+    # https://docs.nvidia.com/cuda/eula/index.html
+    # https://www.intel.com/content/www/us/en/developer/articles/license/onemkl-license-faq.html
+    license = licenses.bsd3;
+    maintainers = with maintainers; [ junjihashimoto ];
+    platforms = platforms.unix;
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/math/libtorch/binary-hashes.nix b/nixpkgs/pkgs/development/libraries/science/math/libtorch/binary-hashes.nix
new file mode 100644
index 000000000000..83533d89b1e8
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/math/libtorch/binary-hashes.nix
@@ -0,0 +1,19 @@
+version : builtins.getAttr version {
+  "2.0.0" = {
+    x86_64-darwin-cpu = {
+      name = "libtorch-macos-2.0.0.zip";
+      url = "https://download.pytorch.org/libtorch/cpu/libtorch-macos-2.0.0.zip";
+      hash = "sha256-u6y5IeYoiOC0yQ/k6JCChDs9lXWccLxUorgR8L62lkM=";
+    };
+    x86_64-linux-cpu = {
+      name = "libtorch-cxx11-abi-shared-with-deps-2.0.0-cpu.zip";
+      url = "https://download.pytorch.org/libtorch/cpu/libtorch-cxx11-abi-shared-with-deps-2.0.0%2Bcpu.zip";
+      hash = "sha256-BoZQ2MC1CDVVGfX3SHC3mEpLGWO8XK7AcLcHJXDsXuc=";
+    };
+    x86_64-linux-cuda = {
+      name = "libtorch-cxx11-abi-shared-with-deps-2.0.0-cu118.zip";
+      url = "https://download.pytorch.org/libtorch/cu118/libtorch-cxx11-abi-shared-with-deps-2.0.0%2Bcu118.zip";
+      hash = "sha256-Dpw9kQdA1NI9EOT7JBKwQP4wZT6lizcnKKTQ8WVJCZc=";
+    };
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/math/libtorch/prefetch.sh b/nixpkgs/pkgs/development/libraries/science/math/libtorch/prefetch.sh
new file mode 100755
index 000000000000..5c6d60ae8b20
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/math/libtorch/prefetch.sh
@@ -0,0 +1,38 @@
+#!/usr/bin/env nix-shell
+#!nix-shell -i bash -p nix-prefetch-scripts
+
+set -eou pipefail
+
+version=$1
+
+bucket="https://download.pytorch.org/libtorch"
+CUDA_VERSION=cu116
+
+url_and_key_list=(
+  "x86_64-darwin-cpu $bucket/cpu/libtorch-macos-${version}.zip libtorch-macos-${version}.zip"
+  "x86_64-linux-cpu $bucket/cpu/libtorch-cxx11-abi-shared-with-deps-${version}%2Bcpu.zip libtorch-cxx11-abi-shared-with-deps-${version}-cpu.zip"
+  "x86_64-linux-cuda $bucket/${CUDA_VERSION}/libtorch-cxx11-abi-shared-with-deps-${version}%2B${CUDA_VERSION}.zip libtorch-cxx11-abi-shared-with-deps-${version}-${CUDA_VERSION}.zip"
+)
+
+hashfile="binary-hashes-$version.nix"
+echo "  \"$version\" = {" >> $hashfile
+
+for url_and_key in "${url_and_key_list[@]}"; do
+  key=$(echo "$url_and_key" | cut -d' ' -f1)
+  url=$(echo "$url_and_key" | cut -d' ' -f2)
+  name=$(echo "$url_and_key" | cut -d' ' -f3)
+
+  echo "prefetching ${url}..."
+  hash=$(nix hash to-sri --type sha256 $(nix-prefetch-url --unpack "$url" --name "$name"))
+
+  echo "    $key = {" >> $hashfile
+  echo "      name = \"$name\";" >> $hashfile
+  echo "      url = \"$url\";" >> $hashfile
+  echo "      hash = \"$hash\";" >> $hashfile
+  echo "    };" >> $hashfile
+
+  echo
+done
+
+echo "  };" >> $hashfile
+echo "done."
diff --git a/nixpkgs/pkgs/development/libraries/science/math/libtorch/test/CMakeLists.txt b/nixpkgs/pkgs/development/libraries/science/math/libtorch/test/CMakeLists.txt
new file mode 100644
index 000000000000..4e96704a4c17
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/math/libtorch/test/CMakeLists.txt
@@ -0,0 +1,5 @@
+cmake_minimum_required(VERSION 3.0)
+find_package(Torch REQUIRED)
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${TORCH_CXX_FLAGS}")
+add_executable(test test.cpp)
+target_link_libraries(test "${TORCH_LIBRARIES}")
diff --git a/nixpkgs/pkgs/development/libraries/science/math/libtorch/test/default.nix b/nixpkgs/pkgs/development/libraries/science/math/libtorch/test/default.nix
new file mode 100644
index 000000000000..a7940cd1db8d
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/math/libtorch/test/default.nix
@@ -0,0 +1,51 @@
+{ lib
+, stdenv
+, cmake
+, libtorch-bin
+, linkFarm
+, symlinkJoin
+
+, cudaSupport
+, cudaPackages ? {}
+}:
+let
+  inherit (cudaPackages) cudatoolkit cudnn;
+
+  cudatoolkit_joined = symlinkJoin {
+    name = "${cudatoolkit.name}-unsplit";
+    paths = [ cudatoolkit.out cudatoolkit.lib ];
+  };
+
+  # We do not have access to /run/opengl-driver/lib in the sandbox,
+  # so use a stub instead.
+  cudaStub = linkFarm "cuda-stub" [{
+    name = "libcuda.so.1";
+    path = "${cudatoolkit}/lib/stubs/libcuda.so";
+  }];
+
+in stdenv.mkDerivation {
+  pname = "libtorch-test";
+  version = libtorch-bin.version;
+
+  src = ./.;
+
+  nativeBuildInputs = [ cmake ];
+
+  buildInputs = [ libtorch-bin ] ++
+    lib.optionals cudaSupport [ cudnn ];
+
+  cmakeFlags = lib.optionals cudaSupport
+    [ "-DCUDA_TOOLKIT_ROOT_DIR=${cudatoolkit_joined}" ];
+
+  doCheck = true;
+
+  installPhase = ''
+    touch $out
+  '';
+
+  checkPhase = lib.optionalString cudaSupport ''
+    LD_LIBRARY_PATH=${cudaStub}''${LD_LIBRARY_PATH:+:}$LD_LIBRARY_PATH \
+  '' + ''
+    ./test
+  '';
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/math/libtorch/test/test.cpp b/nixpkgs/pkgs/development/libraries/science/math/libtorch/test/test.cpp
new file mode 100644
index 000000000000..ca238fba521d
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/math/libtorch/test/test.cpp
@@ -0,0 +1,20 @@
+#undef NDEBUG
+#include <cassert>
+
+#include <iostream>
+
+#include <torch/torch.h>
+
+int main() {
+  torch::Tensor tensor = torch::eye(3);
+
+  float checkData[] = {
+    1, 0, 0,
+    0, 1, 0,
+    0, 0, 1
+  };
+
+  torch::Tensor check = torch::from_blob(checkData, {3, 3});
+
+  assert(tensor.allclose(check));
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/math/lrs/default.nix b/nixpkgs/pkgs/development/libraries/science/math/lrs/default.nix
new file mode 100644
index 000000000000..6fa8567355a9
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/math/lrs/default.nix
@@ -0,0 +1,26 @@
+{ lib, stdenv, fetchurl, gmp }:
+
+stdenv.mkDerivation {
+  pname = "lrs";
+  version = "7.2";
+
+  src = fetchurl {
+    url = "http://cgm.cs.mcgill.ca/~avis/C/lrslib/archive/lrslib-072.tar.gz";
+    sha256 = "1w1jsnfgny8cihndr5gfm99pvwp48qsvxkqfsi2q87gd3m57aj7w";
+  };
+
+  buildInputs = [ gmp ];
+
+  makeFlags = [
+    "prefix=${placeholder "out"}"
+    "CC:=$(CC)"
+  ];
+
+  meta = {
+    description = "Implementation of the reverse search algorithm for vertex enumeration/convex hull problems";
+    license = lib.licenses.gpl2;
+    maintainers = [ lib.maintainers.raskin ];
+    platforms = lib.platforms.linux;
+    homepage = "http://cgm.cs.mcgill.ca/~avis/C/lrs.html";
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/math/m4ri/default.nix b/nixpkgs/pkgs/development/libraries/science/math/m4ri/default.nix
new file mode 100644
index 000000000000..26e26e4ffdbc
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/math/m4ri/default.nix
@@ -0,0 +1,30 @@
+{ lib, stdenv
+, fetchFromBitbucket
+, autoreconfHook
+}:
+
+stdenv.mkDerivation rec {
+  version = "20200125";
+  pname = "m4ri";
+
+  src = fetchFromBitbucket {
+    owner = "malb";
+    repo = "m4ri";
+    rev = "release-${version}";
+    sha256 = "1dxgbv6zdyki3h61qlv7003wzhy6x14zmcaz9x19md1i7ng07w1k";
+  };
+
+  doCheck = true;
+
+  nativeBuildInputs = [
+    autoreconfHook
+  ];
+
+  meta = with lib; {
+    homepage = "https://malb.bitbucket.io/m4ri/";
+    description = "Library to do fast arithmetic with dense matrices over F_2";
+    license = licenses.gpl2Plus;
+    maintainers = teams.sage.members;
+    platforms = platforms.unix;
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/math/m4rie/default.nix b/nixpkgs/pkgs/development/libraries/science/math/m4rie/default.nix
new file mode 100644
index 000000000000..214f27046527
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/math/m4rie/default.nix
@@ -0,0 +1,41 @@
+{ lib, stdenv
+, fetchFromBitbucket
+, autoreconfHook
+, m4ri
+}:
+
+stdenv.mkDerivation rec {
+  version = "20200125";
+  pname = "m4rie";
+
+  src = fetchFromBitbucket {
+    owner = "malb";
+    repo = "m4rie";
+    rev = "release-${version}";
+    sha256 = "sha256-bjAcxfXsC6+jPYC472CN78jm4UljJQlkWyvsqckCDh0=";
+  };
+
+  doCheck = true;
+
+  buildInputs = [
+    m4ri
+  ];
+
+  nativeBuildInputs = [
+    autoreconfHook
+  ];
+
+  meta = with lib; {
+    homepage = "https://malb.bitbucket.io/m4rie/";
+    description = "Library for matrix multiplication, reduction and inversion over GF(2^k) for 2 <= k <= 10";
+    longDescription = ''
+      M4RIE is a library for fast arithmetic with dense matrices over small finite fields of even characteristic.
+      It uses the M4RI library, implementing the same operations over the finite field F2.
+    '';
+    license = licenses.gpl2Plus;
+    maintainers = teams.sage.members;
+    platforms = platforms.unix;
+    # never built on aarch64-darwin since first introduction in nixpkgs
+    broken = stdenv.isDarwin && stdenv.isAarch64;
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/math/magma/default.nix b/nixpkgs/pkgs/development/libraries/science/math/magma/default.nix
new file mode 100644
index 000000000000..9eb410595974
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/math/magma/default.nix
@@ -0,0 +1,53 @@
+args@{ callPackage
+, lib
+, ...
+}:
+
+# Type aliases
+# Release = {
+#  version: String
+#  hash: String
+#  supportedGpuTargets: List String
+# }
+
+let
+  inherit (lib) lists strings trivial;
+
+  computeName = version: "magma_${strings.replaceStrings [ "." ] [ "_" ] version}";
+
+  # buildMagmaPackage :: Release -> Derivation
+  buildMagmaPackage = magmaRelease: callPackage ./generic.nix (
+    (builtins.removeAttrs args [ "callPackage" ]) // {
+      inherit magmaRelease;
+    }
+  );
+
+  # Reverse the list to have the latest release first
+  # magmaReleases :: List Release
+  magmaReleases = lists.reverseList (builtins.import ./releases.nix);
+
+  # The latest release is the first element of the list and will be our default choice
+  # latestReleaseName :: String
+  latestReleaseName = computeName (builtins.head magmaReleases).version;
+
+  # Function to transform our releases into build attributes
+  # toBuildAttrs :: Release -> { name: String, value: Derivation }
+  toBuildAttrs = release: {
+    name = computeName release.version;
+    value = buildMagmaPackage release;
+  };
+
+  # Add all supported builds as attributes
+  # allBuilds :: AttrSet String Derivation
+  allBuilds = builtins.listToAttrs (lists.map toBuildAttrs magmaReleases);
+
+  # The latest release will be our default build
+  # defaultBuild :: AttrSet String Derivation
+  defaultBuild.magma = allBuilds.${latestReleaseName};
+
+  # builds :: AttrSet String Derivation
+  builds = allBuilds // defaultBuild;
+in
+
+builds
+
diff --git a/nixpkgs/pkgs/development/libraries/science/math/magma/generic.nix b/nixpkgs/pkgs/development/libraries/science/math/magma/generic.nix
new file mode 100644
index 000000000000..7ef60e0418ed
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/math/magma/generic.nix
@@ -0,0 +1,173 @@
+# Type aliases
+# Release = {
+#  version: String
+#  hash: String
+#  supportedGpuTargets: List String
+# }
+
+{ blas
+, cmake
+, cudaPackages
+, cudaSupport ? config.cudaSupport
+, fetchurl
+, gfortran
+, cudaCapabilities ? cudaPackages.cudaFlags.cudaCapabilities
+, gpuTargets ? [ ] # Non-CUDA targets, that is HIP
+, rocmPackages
+, lapack
+, lib
+, libpthreadstubs
+, magmaRelease
+, ninja
+, config
+  # At least one back-end has to be enabled,
+  # and we can't default to CUDA since it's unfree
+, rocmSupport ? !cudaSupport
+, static ? stdenv.hostPlatform.isStatic
+, stdenv
+, symlinkJoin
+}:
+
+
+let
+  inherit (lib) lists strings trivial;
+  inherit (cudaPackages) backendStdenv cudaFlags cudaVersion;
+  inherit (magmaRelease) version hash supportedGpuTargets;
+
+  # NOTE: The lists.subtractLists function is perhaps a bit unintuitive. It subtracts the elements
+  #   of the first list *from* the second list. That means:
+  #   lists.subtractLists a b = b - a
+
+  # For ROCm
+  # NOTE: The hip.gpuTargets are prefixed with "gfx" instead of "sm" like cudaFlags.realArches.
+  #   For some reason, Magma's CMakeLists.txt file does not handle the "gfx" prefix, so we must
+  #   remove it.
+  rocmArches = lists.map (x: strings.removePrefix "gfx" x) rocmPackages.clr.gpuTargets;
+  supportedRocmArches = lists.intersectLists rocmArches supportedGpuTargets;
+  unsupportedRocmArches = lists.subtractLists supportedRocmArches rocmArches;
+
+  supportedCustomGpuTargets = lists.intersectLists gpuTargets supportedGpuTargets;
+  unsupportedCustomGpuTargets = lists.subtractLists supportedCustomGpuTargets gpuTargets;
+
+  # Use trivial.warnIf to print a warning if any unsupported GPU targets are specified.
+  gpuArchWarner = supported: unsupported:
+    trivial.throwIf (supported == [ ])
+      (
+        "No supported GPU targets specified. Requested GPU targets: "
+        + strings.concatStringsSep ", " unsupported
+      )
+      supported;
+
+  gpuTargetString = strings.concatStringsSep "," (
+    if gpuTargets != [ ] then
+    # If gpuTargets is specified, it always takes priority.
+      gpuArchWarner supportedCustomGpuTargets unsupportedCustomGpuTargets
+    else if rocmSupport then
+      gpuArchWarner supportedRocmArches unsupportedRocmArches
+    else if cudaSupport then
+      [ ] # It's important we pass explicit -DGPU_TARGET to reset magma's defaults
+    else
+      throw "No GPU targets specified"
+  );
+
+  # E.g. [ "80" "86" "90" ]
+  cudaArchitectures = (builtins.map cudaFlags.dropDot cudaCapabilities);
+
+  cudaArchitecturesString = strings.concatStringsSep ";" cudaArchitectures;
+  minArch =
+    let
+      minArch' = builtins.head (builtins.sort strings.versionOlder cudaArchitectures);
+    in
+    # "75" -> "750"  Cf. https://bitbucket.org/icl/magma/src/f4ec79e2c13a2347eff8a77a3be6f83bc2daec20/CMakeLists.txt#lines-273
+    "${minArch'}0";
+
+in
+
+assert (builtins.match "[^[:space:]]*" gpuTargetString) != null;
+
+stdenv.mkDerivation {
+  pname = "magma";
+  inherit version;
+
+  src = fetchurl {
+    name = "magma-${version}.tar.gz";
+    url = "https://icl.cs.utk.edu/projectsfiles/magma/downloads/magma-${version}.tar.gz";
+    inherit hash;
+  };
+
+  nativeBuildInputs = [
+    cmake
+    ninja
+    gfortran
+  ] ++ lists.optionals cudaSupport [
+    cudaPackages.cuda_nvcc
+  ];
+
+  buildInputs = [
+    libpthreadstubs
+    lapack
+    blas
+  ] ++ lists.optionals cudaSupport (with cudaPackages; [
+    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
+  ] ++ lists.optionals (strings.versionOlder cudaVersion "11.8") [
+    cuda_nvprof.dev # <cuda_profiler_api.h>
+  ] ++ lists.optionals (strings.versionAtLeast cudaVersion "11.8") [
+    cuda_profiler_api.dev # <cuda_profiler_api.h>
+  ] ++ lists.optionals (strings.versionAtLeast cudaVersion "12.0") [
+    cuda_cccl.dev # <nv/target>
+  ]) ++ lists.optionals rocmSupport [
+    rocmPackages.clr
+    rocmPackages.hipblas
+    rocmPackages.hipsparse
+    rocmPackages.llvm.openmp
+  ];
+
+  cmakeFlags = [
+    "-DGPU_TARGET=${gpuTargetString}"
+    (lib.cmakeBool "MAGMA_ENABLE_CUDA" cudaSupport)
+    (lib.cmakeBool "MAGMA_ENABLE_HIP" rocmSupport)
+  ] ++ lists.optionals static [
+    "-DBUILD_SHARED_LIBS=OFF"
+  ] ++ lists.optionals cudaSupport [
+    "-DCMAKE_CUDA_ARCHITECTURES=${cudaArchitecturesString}"
+    "-DMIN_ARCH=${minArch}" # Disarms magma's asserts
+    "-DCMAKE_C_COMPILER=${backendStdenv.cc}/bin/cc"
+    "-DCMAKE_CXX_COMPILER=${backendStdenv.cc}/bin/c++"
+  ] ++ lists.optionals rocmSupport [
+    "-DCMAKE_C_COMPILER=${rocmPackages.clr}/bin/hipcc"
+    "-DCMAKE_CXX_COMPILER=${rocmPackages.clr}/bin/hipcc"
+  ] ++ lists.optionals (cudaPackages.cudaAtLeast "12.0.0") [
+    (lib.cmakeBool "USE_FORTRAN" false)
+  ];
+
+  buildFlags = [
+    "magma"
+    "magma_sparse"
+  ];
+
+  doCheck = false;
+
+  passthru = {
+    inherit cudaPackages cudaSupport rocmSupport gpuTargets;
+  };
+
+  meta = with lib; {
+    description = "Matrix Algebra on GPU and Multicore Architectures";
+    license = licenses.bsd3;
+    homepage = "http://icl.cs.utk.edu/magma/index.html";
+    platforms = platforms.linux;
+    maintainers = with maintainers; [ connorbaker ];
+
+    # Cf. https://bitbucket.org/icl/magma/src/fcfe5aa61c1a4c664b36a73ebabbdbab82765e9f/CMakeLists.txt#lines-20
+    broken =
+      !(cudaSupport || rocmSupport) # At least one back-end enabled
+      || (cudaSupport && rocmSupport) # Mutually exclusive
+      || (cudaSupport && strings.versionOlder cudaVersion "9");
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/math/magma/releases.nix b/nixpkgs/pkgs/development/libraries/science/math/magma/releases.nix
new file mode 100644
index 000000000000..59f495d67109
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/math/magma/releases.nix
@@ -0,0 +1,69 @@
+# NOTE: Order matters! Put the oldest version first, and the newest version last.
+# NOTE: Make sure the supportedGpuTargets are in order of oldest to newest.
+#   You can update the supportedGpuTargets by looking at the CMakeLists.txt file.
+#   HIP is here: https://bitbucket.org/icl/magma/src/f4ec79e2c13a2347eff8a77a3be6f83bc2daec20/CMakeLists.txt#lines-386
+#   CUDA works around magma's wrappers and uses FindCUDAToolkit directly
+[
+  {
+    version = "2.6.2";
+    hash = "sha256-dbVU2rAJA+LRC5cskT5Q5/iMvGLzrkMrWghsfk7aCnE=";
+    supportedGpuTargets = [
+      "700"
+      "701"
+      "702"
+      "703"
+      "704"
+      "705"
+      "801"
+      "802"
+      "803"
+      "805"
+      "810"
+      "900"
+      "902"
+      "904"
+      "906"
+      "908"
+      "909"
+      "90c"
+      "1010"
+      "1011"
+      "1012"
+      "1030"
+      "1031"
+      "1032"
+      "1033"
+    ];
+  }
+  {
+    version = "2.7.2";
+    hash = "sha256-cpvBpw5RinQi/no6VFN6R0EDWne+M0n2bqxcNiV21WA=";
+    supportedGpuTargets = [
+      "700"
+      "701"
+      "702"
+      "703"
+      "704"
+      "705"
+      "801"
+      "802"
+      "803"
+      "805"
+      "810"
+      "900"
+      "902"
+      "904"
+      "906"
+      "908"
+      "909"
+      "90c"
+      "1010"
+      "1011"
+      "1012"
+      "1030"
+      "1031"
+      "1032"
+      "1033"
+    ];
+  }
+]
diff --git a/nixpkgs/pkgs/development/libraries/science/math/metis/default.nix b/nixpkgs/pkgs/development/libraries/science/math/metis/default.nix
new file mode 100644
index 000000000000..cd221e86b148
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/math/metis/default.nix
@@ -0,0 +1,25 @@
+{ lib, stdenv, fetchurl, unzip, cmake }:
+
+stdenv.mkDerivation rec {
+  pname = "metis";
+  version = "5.1.0";
+
+  src = fetchurl {
+    url = "http://glaros.dtc.umn.edu/gkhome/fetch/sw/metis/metis-${version}.tar.gz";
+    sha256 = "1cjxgh41r8k6j029yxs8msp3z6lcnpm16g5pvckk35kc7zhfpykn";
+  };
+
+  cmakeFlags = [
+    "-DGKLIB_PATH=../GKlib"
+    # remove once updated past https://github.com/KarypisLab/METIS/commit/521a2c360dc21ace5c4feb6dc0b7992433e3cb0f
+    "-DCMAKE_SKIP_BUILD_RPATH=ON"
+  ];
+  nativeBuildInputs = [ unzip cmake ];
+
+  meta = {
+    description = "Serial graph partitioning and fill-reducing matrix ordering";
+    homepage = "http://glaros.dtc.umn.edu/gkhome/metis/metis/overview";
+    license = lib.licenses.asl20;
+    platforms = lib.platforms.all;
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/math/mkl/default.nix b/nixpkgs/pkgs/development/libraries/science/math/mkl/default.nix
new file mode 100644
index 000000000000..90e6c05da77d
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/math/mkl/default.nix
@@ -0,0 +1,184 @@
+{ lib
+, stdenv
+, callPackage
+, stdenvNoCC
+, fetchurl
+, rpmextract
+, _7zz
+, darwin
+, validatePkgConfig
+, enableStatic ? stdenv.hostPlatform.isStatic
+}:
+
+/*
+  For details on using mkl as a blas provider for python packages such as numpy,
+  numexpr, scipy, etc., see the Python section of the NixPkgs manual.
+*/
+let
+  # Release notes and download URLs are here:
+  # https://registrationcenter.intel.com/en/products/
+  version = "${mklVersion}.${rel}";
+
+  mklVersion = "2023.1.0";
+  rel = if stdenvNoCC.isDarwin then "43558" else "46342";
+
+  # Intel openmp uses its own versioning.
+  openmpVersion = "2023.1.0";
+  openmpRel = "46305";
+
+  # Thread Building Blocks release.
+  tbbVersion = "2021.9.0";
+  tbbRel = "43484";
+
+  shlibExt = stdenvNoCC.hostPlatform.extensions.sharedLibrary;
+
+  oneapi-mkl = fetchurl {
+    url = "https://yum.repos.intel.com/oneapi/intel-oneapi-mkl-${mklVersion}-${mklVersion}-${rel}.x86_64.rpm";
+    hash = "sha256-PGLPNnR+11AmmaNxldeze/l2Kw/4+mfjB+RqsPhP6oM=";
+  };
+
+  oneapi-mkl-common = fetchurl {
+    url = "https://yum.repos.intel.com/oneapi/intel-oneapi-mkl-common-${mklVersion}-${mklVersion}-${rel}.noarch.rpm";
+    hash = "sha256-wztTE2R/IdG6ujGf7KFocpRmXzlZSnEKopTBOlPPlBw=";
+  };
+
+  oneapi-mkl-common-devel = fetchurl {
+    url = "https://yum.repos.intel.com/oneapi/intel-oneapi-mkl-common-devel-${mklVersion}-${mklVersion}-${rel}.noarch.rpm";
+    hash = "sha256-MWa8mpyFM4zgDLup+EzFRM+N2Oxf0o6FBBRM8mAanbI=";
+  };
+
+  oneapi-mkl-devel = fetchurl {
+    url = "https://yum.repos.intel.com/oneapi/intel-oneapi-mkl-devel-${mklVersion}-${mklVersion}-${rel}.x86_64.rpm";
+    hash = "sha256-Arq5kXktI92031XqfV0pkzQCHaFsTRKX05iOA/fPNOs=";
+  };
+
+  oneapi-openmp = fetchurl {
+    url = "https://yum.repos.intel.com/oneapi/intel-oneapi-openmp-${mklVersion}-${mklVersion}-${openmpRel}.x86_64.rpm";
+    hash = "sha256-cyBD3P4AEvyreP4pP3BE+yyDB+ptblOQ9GYI8ysGsIM=";
+  };
+
+  oneapi-tbb = fetchurl {
+    url = "https://yum.repos.intel.com/oneapi/intel-oneapi-tbb-${tbbVersion}-${tbbVersion}-${tbbRel}.x86_64.rpm";
+    hash = "sha256-pzJpQdiYVpcKDShePak2I0uEh7u08vJgX7OBF5p5yAM=";
+  };
+
+in stdenvNoCC.mkDerivation ({
+  pname = "mkl";
+  inherit version;
+
+  dontUnpack = stdenvNoCC.isLinux;
+
+  sourceRoot = if stdenvNoCC.isDarwin then "." else null;
+
+  nativeBuildInputs = [ validatePkgConfig ] ++ (if stdenvNoCC.isDarwin
+    then
+      [ _7zz darwin.cctools ]
+    else
+      [ rpmextract ]);
+
+  buildPhase = if stdenvNoCC.isDarwin then ''
+    for f in bootstrapper.app/Contents/Resources/packages/*/cupPayload.cup; do
+      tar -xf $f
+    done
+    mkdir -p opt/intel
+    mv _installdir opt/intel/oneapi
+  '' else ''
+    rpmextract ${oneapi-mkl}
+    rpmextract ${oneapi-mkl-common}
+    rpmextract ${oneapi-mkl-common-devel}
+    rpmextract ${oneapi-mkl-devel}
+    rpmextract ${oneapi-openmp}
+    rpmextract ${oneapi-tbb}
+  '';
+
+  installPhase = ''
+    for f in $(find . -name 'mkl*.pc') ; do
+      bn=$(basename $f)
+      substituteInPlace $f \
+        --replace $\{MKLROOT} "$out" \
+        --replace "lib/intel64" "lib"
+
+      sed -r -i "s|^prefix=.*|prefix=$out|g" $f
+    done
+
+    for f in $(find opt/intel -name 'mkl*iomp.pc') ; do
+      substituteInPlace $f --replace "../compiler/lib" "lib"
+    done
+
+    # License
+    install -Dm0655 -t $out/share/doc/mkl opt/intel/oneapi/mkl/${mklVersion}/licensing/license.txt
+
+    # Dynamic libraries
+    mkdir -p $out/lib
+    cp -a opt/intel/oneapi/mkl/${mklVersion}/lib/${lib.optionalString stdenvNoCC.isLinux "intel64"}/*${shlibExt}* $out/lib
+    cp -a opt/intel/oneapi/compiler/${mklVersion}/${if stdenvNoCC.isDarwin then "mac" else "linux"}/compiler/lib/${lib.optionalString stdenvNoCC.isLinux "intel64_lin"}/*${shlibExt}* $out/lib
+    cp -a opt/intel/oneapi/tbb/${tbbVersion}/lib/${lib.optionalString stdenvNoCC.isLinux "intel64/gcc4.8"}/*${shlibExt}* $out/lib
+
+    # Headers
+    cp -r opt/intel/oneapi/mkl/${mklVersion}/include $out/
+
+    # CMake config
+    cp -r opt/intel/oneapi/mkl/${mklVersion}/lib/cmake $out/lib
+  '' +
+    (if enableStatic then ''
+      install -Dm0644 -t $out/lib opt/intel/oneapi/mkl/${mklVersion}/lib/${lib.optionalString stdenvNoCC.isLinux "intel64"}/*.a
+      install -Dm0644 -t $out/lib/pkgconfig opt/intel/oneapi/mkl/${mklVersion}/lib/pkgconfig/*.pc
+    '' else ''
+      cp opt/intel/oneapi/mkl/${mklVersion}/lib/${lib.optionalString stdenvNoCC.isLinux "intel64"}/*${shlibExt}* $out/lib
+      install -Dm0644 -t $out/lib/pkgconfig opt/intel/oneapi/mkl/${mklVersion}/lib/pkgconfig/*dynamic*.pc
+    '') + ''
+    # Setup symlinks for blas / lapack
+    ln -s $out/lib/libmkl_rt${shlibExt} $out/lib/libblas${shlibExt}
+    ln -s $out/lib/libmkl_rt${shlibExt} $out/lib/libcblas${shlibExt}
+    ln -s $out/lib/libmkl_rt${shlibExt} $out/lib/liblapack${shlibExt}
+    ln -s $out/lib/libmkl_rt${shlibExt} $out/lib/liblapacke${shlibExt}
+  '' + lib.optionalString stdenvNoCC.hostPlatform.isLinux ''
+    ln -s $out/lib/libmkl_rt${shlibExt} $out/lib/libblas${shlibExt}".3"
+    ln -s $out/lib/libmkl_rt${shlibExt} $out/lib/libcblas${shlibExt}".3"
+    ln -s $out/lib/libmkl_rt${shlibExt} $out/lib/liblapack${shlibExt}".3"
+    ln -s $out/lib/libmkl_rt${shlibExt} $out/lib/liblapacke${shlibExt}".3"
+  '';
+
+  # fixDarwinDylibName fails for libmkl_cdft_core.dylib because the
+  # larger updated load commands do not fit. Use install_name_tool
+  # explicitly and ignore the error.
+  postFixup = lib.optionalString stdenvNoCC.isDarwin ''
+    for f in $out/lib/*.dylib; do
+      install_name_tool -id $out/lib/$(basename $f) $f || true
+    done
+    install_name_tool -change @rpath/libiomp5.dylib $out/lib/libiomp5.dylib $out/lib/libmkl_intel_thread.dylib
+    install_name_tool -change @rpath/libtbb.12.dylib $out/lib/libtbb.12.dylib $out/lib/libmkl_tbb_thread.dylib
+    install_name_tool -change @rpath/libtbbmalloc.2.dylib $out/lib/libtbbmalloc.2.dylib $out/lib/libtbbmalloc_proxy.dylib
+  '';
+
+  # Per license agreement, do not modify the binary
+  dontStrip = true;
+  dontPatchELF = true;
+
+  passthru.tests = {
+    pkg-config-dynamic-iomp = callPackage ./test { enableStatic = false; execution = "iomp"; };
+    pkg-config-static-iomp = callPackage ./test { enableStatic = true; execution = "iomp"; };
+    pkg-config-dynamic-seq = callPackage ./test { enableStatic = false; execution = "seq"; };
+    pkg-config-static-seq = callPackage ./test { enableStatic = true; execution = "seq"; };
+  };
+
+  meta = with lib; {
+    description = "Intel OneAPI Math Kernel Library";
+    longDescription = ''
+      Intel OneAPI Math Kernel Library (Intel oneMKL) optimizes code with minimal
+      effort for future generations of Intel processors. It is compatible with your
+      choice of compilers, languages, operating systems, and linking and
+      threading models.
+    '';
+    homepage = "https://software.intel.com/en-us/mkl";
+    sourceProvenance = with sourceTypes; [ binaryNativeCode ];
+    license = licenses.issl;
+    platforms = [ "x86_64-linux" "x86_64-darwin" ];
+    maintainers = with maintainers; [ bhipple ];
+  };
+} // lib.optionalAttrs stdenvNoCC.isDarwin {
+  src = fetchurl {
+    url = "https://registrationcenter-download.intel.com/akdlm/IRC_NAS/087a9190-9d96-4b8c-bd2f-79159572ed89/m_onemkl_p_${mklVersion}.${rel}_offline.dmg";
+    hash = "sha256-bUaaJPSaLr60fw0DzDCjPvY/UucHlLbCSLyQxyiAi04=";
+  };
+})
diff --git a/nixpkgs/pkgs/development/libraries/science/math/mkl/test/default.nix b/nixpkgs/pkgs/development/libraries/science/math/mkl/test/default.nix
new file mode 100644
index 000000000000..cb3355260d12
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/math/mkl/test/default.nix
@@ -0,0 +1,41 @@
+{ stdenv
+, pkg-config
+, mkl
+
+, enableStatic ? false
+, execution ? "seq"
+}:
+
+let
+  linkType = if enableStatic then "static" else "dynamic";
+in stdenv.mkDerivation {
+  pname = "mkl-test";
+  version = mkl.version;
+
+  src = ./.;
+
+  nativeBuildInputs = [ pkg-config ];
+
+  buildInputs = [ (mkl.override { inherit enableStatic; }) ];
+
+  doCheck = true;
+
+  buildPhase = ''
+    # Check regular Nix build.
+    gcc test.c -o test $(pkg-config --cflags --libs mkl-${linkType}-ilp64-${execution})
+
+    # Clear flags to ensure that we are purely relying on options
+    # provided by pkg-config.
+    NIX_CFLAGS_COMPILE="" \
+    NIX_LDFLAGS="" \
+      gcc test.c -o test $(pkg-config --cflags --libs mkl-${linkType}-ilp64-${execution})
+  '';
+
+  installPhase = ''
+    touch $out
+  '';
+
+  checkPhase = ''
+    ./test
+  '';
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/math/mkl/test/test.c b/nixpkgs/pkgs/development/libraries/science/math/mkl/test/test.c
new file mode 100644
index 000000000000..9413ac0c68e9
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/math/mkl/test/test.c
@@ -0,0 +1,12 @@
+#include <assert.h>
+
+#include <mkl_cblas.h>
+
+int main() {
+  float u[] = {1., 2., 3.};
+  float v[] = {4., 5., 6.};
+
+  float dp = cblas_sdot(3, u, 1, v, 1);
+
+  assert(dp == 32.);
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/math/mongoose/default.nix b/nixpkgs/pkgs/development/libraries/science/math/mongoose/default.nix
new file mode 100644
index 000000000000..29b901277f61
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/math/mongoose/default.nix
@@ -0,0 +1,69 @@
+{ lib
+, stdenv
+, fetchFromGitHub
+, cmake
+, blas
+, llvmPackages
+}:
+
+let
+  suitesparseVersion = "7.6.0";
+in
+stdenv.mkDerivation {
+  pname = "mongoose";
+  version = "3.3.2";
+
+  outputs = [ "bin" "out" "dev" ];
+
+  src = fetchFromGitHub {
+    owner = "DrTimothyAldenDavis";
+    repo = "SuiteSparse";
+    rev = "v${suitesparseVersion}";
+    hash = "sha256-zZXbUNXxVi4mpI4j4GjyVYraoPFWcuep9q5jl1XdqEo=";
+  };
+
+  nativeBuildInputs = [
+    cmake
+  ];
+
+  buildInputs = [
+    blas
+  ] ++ lib.optionals stdenv.cc.isClang [
+    llvmPackages.openmp
+  ];
+
+  dontUseCmakeConfigure = true;
+
+  cmakeFlags = [
+    "-DBLAS_LIBRARIES=${blas}"
+    "-DCMAKE_BUILD_WITH_INSTALL_NAME_DIR=ON"
+  ];
+
+  buildPhase = ''
+    runHook preConfigure
+
+    for f in SuiteSparse_config Mongoose; do
+      (cd $f && cmakeConfigurePhase && make -j$NIX_BUILD_CORES)
+    done
+
+    runHook postConfigure
+  '';
+
+  installPhase = ''
+    runHook preInstall
+
+    for f in SuiteSparse_config Mongoose; do
+      (cd $f/build && make install -j$NIX_BUILD_CORES)
+    done
+
+    runHook postInstall
+  '';
+
+  meta = with lib; {
+    description = "Graph Coarsening and Partitioning Library";
+    homepage = "https://github.com/DrTimothyAldenDavis/SuiteSparse/tree/dev/Mongoose";
+    license = licenses.gpl3Only;
+    maintainers = with maintainers; [ wegank ];
+    platforms = with platforms; unix;
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/math/openblas/default.nix b/nixpkgs/pkgs/development/libraries/science/math/openblas/default.nix
new file mode 100644
index 000000000000..7ecd6a88d13c
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/math/openblas/default.nix
@@ -0,0 +1,269 @@
+{ lib, stdenv, fetchFromGitHub, fetchpatch, perl, which
+# Most packages depending on openblas expect integer width to match
+# pointer width, but some expect to use 32-bit integers always
+# (for compatibility with reference BLAS).
+, blas64 ? null
+# Multi-threaded applications must not call a threaded OpenBLAS
+# (the only exception is when an application uses OpenMP as its
+# *only* form of multi-threading). See
+#     https://github.com/OpenMathLib/OpenBLAS/wiki/Faq/4bded95e8dc8aadc70ce65267d1093ca7bdefc4c#multi-threaded
+#     https://github.com/OpenMathLib/OpenBLAS/issues/2543
+# This flag builds a single-threaded OpenBLAS using the flags
+# stated in thre.
+, singleThreaded ? false
+, buildPackages
+# Select a specific optimization target (other than the default)
+# See https://github.com/OpenMathLib/OpenBLAS/blob/develop/TargetList.txt
+, target ? null
+# Select whether DYNAMIC_ARCH is enabled or not.
+, dynamicArch ? null
+# enable AVX512 optimized kernels.
+# These kernels have been a source of trouble in the past.
+# Use with caution.
+, enableAVX512 ? false
+, enableStatic ? stdenv.hostPlatform.isStatic
+, enableShared ? !stdenv.hostPlatform.isStatic
+
+# for passthru.tests
+, ceres-solver
+, giac
+, octave
+, opencv
+, python3
+, openmp ? null
+}:
+
+let blas64_ = blas64; in
+
+let
+  setTarget = x: if target == null then x else target;
+  setDynamicArch = x: if dynamicArch == null then x else dynamicArch;
+
+  # To add support for a new platform, add an element to this set.
+  configs = {
+    armv6l-linux = {
+      BINARY = 32;
+      TARGET = setTarget "ARMV6";
+      DYNAMIC_ARCH = setDynamicArch false;
+      USE_OPENMP = true;
+    };
+
+    armv7l-linux = {
+      BINARY = 32;
+      TARGET = setTarget "ARMV7";
+      DYNAMIC_ARCH = setDynamicArch false;
+      USE_OPENMP = true;
+    };
+
+    aarch64-darwin = {
+      BINARY = 64;
+      TARGET = setTarget "VORTEX";
+      DYNAMIC_ARCH = setDynamicArch true;
+      USE_OPENMP = false;
+      MACOSX_DEPLOYMENT_TARGET = "11.0";
+    };
+
+    aarch64-linux = {
+      BINARY = 64;
+      TARGET = setTarget "ARMV8";
+      DYNAMIC_ARCH = setDynamicArch true;
+      USE_OPENMP = true;
+    };
+
+    i686-linux = {
+      BINARY = 32;
+      TARGET = setTarget "P2";
+      DYNAMIC_ARCH = setDynamicArch true;
+      USE_OPENMP = true;
+    };
+
+    x86_64-darwin = {
+      BINARY = 64;
+      TARGET = setTarget "ATHLON";
+      DYNAMIC_ARCH = setDynamicArch true;
+      NO_AVX512 = !enableAVX512;
+      USE_OPENMP = false;
+      MACOSX_DEPLOYMENT_TARGET = "10.7";
+    };
+
+    x86_64-linux = {
+      BINARY = 64;
+      TARGET = setTarget "ATHLON";
+      DYNAMIC_ARCH = setDynamicArch true;
+      NO_AVX512 = !enableAVX512;
+      USE_OPENMP = !stdenv.hostPlatform.isMusl;
+    };
+
+    powerpc64le-linux = {
+      BINARY = 64;
+      TARGET = setTarget "POWER5";
+      DYNAMIC_ARCH = setDynamicArch true;
+      USE_OPENMP = !stdenv.hostPlatform.isMusl;
+    };
+
+    riscv64-linux = {
+      BINARY = 64;
+      TARGET = setTarget "RISCV64_GENERIC";
+      DYNAMIC_ARCH = setDynamicArch false;
+      USE_OPENMP = true;
+    };
+
+    loongarch64-linux = {
+      BINARY = 64;
+      TARGET = setTarget "LOONGSONGENERIC";
+      DYNAMIC_ARCH = setDynamicArch false;
+      USE_OPENMP = true;
+    };
+  };
+in
+
+let
+  config =
+    configs.${stdenv.hostPlatform.system}
+    or (throw "unsupported system: ${stdenv.hostPlatform.system}");
+in
+
+let
+  blas64 =
+    if blas64_ != null
+      then blas64_
+      else lib.hasPrefix "x86_64" stdenv.hostPlatform.system;
+  # Convert flag values to format OpenBLAS's build expects.
+  # `toString` is almost what we need other than bools,
+  # which we need to map {true -> 1, false -> 0}
+  # (`toString` produces empty string `""` for false instead of `0`)
+  mkMakeFlagValue = val:
+    if !builtins.isBool val then toString val
+    else if val then "1" else "0";
+  mkMakeFlagsFromConfig = lib.mapAttrsToList (var: val: "${var}=${mkMakeFlagValue val}");
+
+  shlibExt = stdenv.hostPlatform.extensions.sharedLibrary;
+
+in
+stdenv.mkDerivation rec {
+  pname = "openblas";
+  version = "0.3.26";
+
+  outputs = [ "out" "dev" ];
+
+  src = fetchFromGitHub {
+    owner = "OpenMathLib";
+    repo = "OpenBLAS";
+    rev = "v${version}";
+    hash = "sha256-AA3+x3SXkcg3g7bROZYLpWAbxnRedmQBZPe+rBJKxJ8=";
+  };
+
+  postPatch = ''
+    # cc1: error: invalid feature modifier 'sve2' in '-march=armv8.5-a+sve+sve2+bf16'
+    substituteInPlace Makefile.arm64 --replace "+sve2+bf16" ""
+  '';
+
+  inherit blas64;
+
+  # Some hardening features are disabled due to sporadic failures in
+  # OpenBLAS-based programs. The problem may not be with OpenBLAS itself, but
+  # with how these flags interact with hardening measures used downstream.
+  # In either case, OpenBLAS must only be used by trusted code--it is
+  # inherently unsuitable for security-conscious applications--so there should
+  # be no objection to disabling these hardening measures.
+  hardeningDisable = [
+    # don't modify or move the stack
+    "stackprotector" "pic"
+    # don't alter index arithmetic
+    "strictoverflow"
+    # don't interfere with dynamic target detection
+    "relro" "bindnow"
+  ];
+
+  nativeBuildInputs = [
+    perl
+    which
+  ];
+
+  buildInputs = lib.optional (stdenv.cc.isClang && config.USE_OPENMP) openmp;
+
+  depsBuildBuild = [
+    buildPackages.gfortran
+    buildPackages.stdenv.cc
+  ];
+
+  enableParallelBuilding = true;
+
+  makeFlags = mkMakeFlagsFromConfig (config // {
+    FC = "${stdenv.cc.targetPrefix}gfortran";
+    CC = "${stdenv.cc.targetPrefix}${if stdenv.cc.isClang then "clang" else "cc"}";
+    PREFIX = placeholder "out";
+    OPENBLAS_INCLUDE_DIR = "${placeholder "dev"}/include";
+    NUM_THREADS = 64;
+    INTERFACE64 = blas64;
+    NO_STATIC = !enableStatic;
+    NO_SHARED = !enableShared;
+    CROSS = stdenv.hostPlatform != stdenv.buildPlatform;
+    HOSTCC = "cc";
+    # Makefile.system only checks defined status
+    # This seems to be a bug in the openblas Makefile:
+    # on x86_64 it expects NO_BINARY_MODE=
+    # but on aarch64 it expects NO_BINARY_MODE=0
+    NO_BINARY_MODE = if stdenv.isx86_64
+        then toString (stdenv.hostPlatform != stdenv.buildPlatform)
+        else stdenv.hostPlatform != stdenv.buildPlatform;
+    # This disables automatic build job count detection (which honours neither enableParallelBuilding nor NIX_BUILD_CORES)
+    # and uses the main make invocation's job count, falling back to 1 if no parallelism is used.
+    # https://github.com/OpenMathLib/OpenBLAS/blob/v0.3.20/getarch.c#L1781-L1792
+    MAKE_NB_JOBS = 0;
+  } // (lib.optionalAttrs stdenv.cc.isClang {
+    LDFLAGS = "-L${lib.getLib buildPackages.gfortran.cc}/lib"; # contains `libgfortran.so`; building with clang needs this, gcc has it implicit
+  }) // (lib.optionalAttrs singleThreaded {
+    # As described on https://github.com/OpenMathLib/OpenBLAS/wiki/Faq/4bded95e8dc8aadc70ce65267d1093ca7bdefc4c#multi-threaded
+    USE_THREAD = false;
+    USE_LOCKING = true; # available with openblas >= 0.3.7
+    USE_OPENMP = false; # openblas will refuse building with both USE_OPENMP=1 and USE_THREAD=0
+  }));
+
+  doCheck = true;
+  checkTarget = "tests";
+
+  postInstall = ''
+    # Write pkgconfig aliases. Upstream report:
+    # https://github.com/OpenMathLib/OpenBLAS/issues/1740
+    for alias in blas cblas lapack; do
+      cat <<EOF > $out/lib/pkgconfig/$alias.pc
+Name: $alias
+Version: ${version}
+Description: $alias provided by the OpenBLAS package.
+Cflags: -I$dev/include
+Libs: -L$out/lib -lopenblas
+EOF
+    done
+
+    # Setup symlinks for blas / lapack
+  '' + lib.optionalString enableShared ''
+    ln -s $out/lib/libopenblas${shlibExt} $out/lib/libblas${shlibExt}
+    ln -s $out/lib/libopenblas${shlibExt} $out/lib/libcblas${shlibExt}
+    ln -s $out/lib/libopenblas${shlibExt} $out/lib/liblapack${shlibExt}
+    ln -s $out/lib/libopenblas${shlibExt} $out/lib/liblapacke${shlibExt}
+  '' + lib.optionalString (stdenv.hostPlatform.isLinux && enableShared) ''
+    ln -s $out/lib/libopenblas${shlibExt} $out/lib/libblas${shlibExt}.3
+    ln -s $out/lib/libopenblas${shlibExt} $out/lib/libcblas${shlibExt}.3
+    ln -s $out/lib/libopenblas${shlibExt} $out/lib/liblapack${shlibExt}.3
+    ln -s $out/lib/libopenblas${shlibExt} $out/lib/liblapacke${shlibExt}.3
+  '' + lib.optionalString enableStatic ''
+    ln -s $out/lib/libopenblas.a $out/lib/libblas.a
+    ln -s $out/lib/libopenblas.a $out/lib/libcblas.a
+    ln -s $out/lib/libopenblas.a $out/lib/liblapack.a
+    ln -s $out/lib/libopenblas.a $out/lib/liblapacke.a
+  '';
+
+  passthru.tests = {
+    inherit (python3.pkgs) numpy scipy;
+    inherit ceres-solver giac octave opencv;
+  };
+
+  meta = with lib; {
+    description = "Basic Linear Algebra Subprograms";
+    license = licenses.bsd3;
+    homepage = "https://github.com/OpenMathLib/OpenBLAS";
+    platforms = attrNames configs;
+    maintainers = with maintainers; [ ttuegel ];
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/math/openlibm/default.nix b/nixpkgs/pkgs/development/libraries/science/math/openlibm/default.nix
new file mode 100644
index 000000000000..4ee82bc0633e
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/math/openlibm/default.nix
@@ -0,0 +1,23 @@
+{ lib, stdenv, fetchFromGitHub }:
+
+stdenv.mkDerivation rec {
+  pname = "openlibm";
+  version = "0.8.2";
+
+  src = fetchFromGitHub {
+    owner = "JuliaLang";
+    repo = "openlibm";
+    rev = "v${version}";
+    sha256 = "sha256-EnpwYtBpY+s5FVI2jhaFHTtAKHeaRlZVnWE/o2T1+FY=";
+  };
+
+  makeFlags = [ "prefix=$(out)" "CC=${stdenv.cc.targetPrefix}cc" ];
+
+  meta = {
+    description = "High quality system independent, portable, open source libm implementation";
+    homepage = "https://openlibm.org/";
+    license = lib.licenses.mit;
+    maintainers = [ lib.maintainers.ttuegel ];
+    platforms = lib.platforms.all;
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/math/openspecfun/default.nix b/nixpkgs/pkgs/development/libraries/science/math/openspecfun/default.nix
new file mode 100644
index 000000000000..14befd6d11fe
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/math/openspecfun/default.nix
@@ -0,0 +1,24 @@
+{ lib, stdenv, fetchFromGitHub, gfortran }:
+
+stdenv.mkDerivation rec {
+  pname = "openspecfun";
+  version = "0.5.6";
+  src = fetchFromGitHub {
+    owner = "JuliaLang";
+    repo = "openspecfun";
+    rev = "v${version}";
+    sha256 = "sha256-4MPoRMtDTkdvDfhNXKk/80pZjXRNEPcysLNTb5ohxWk=";
+  };
+
+  makeFlags = [ "prefix=$(out)" ];
+
+  nativeBuildInputs = [ gfortran ];
+
+  meta = {
+    description = "A collection of special mathematical functions";
+    homepage = "https://github.com/JuliaLang/openspecfun";
+    license = lib.licenses.mit;
+    maintainers = [ lib.maintainers.ttuegel ];
+    platforms = lib.platforms.all;
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/math/or-tools/default.nix b/nixpkgs/pkgs/development/libraries/science/math/or-tools/default.nix
new file mode 100644
index 000000000000..5cbc23589895
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/math/or-tools/default.nix
@@ -0,0 +1,126 @@
+{ abseil-cpp
+, bzip2
+, cbc
+, cmake
+, eigen
+, ensureNewerSourcesForZipFilesHook
+, fetchFromGitHub
+, fetchpatch
+, glpk
+, lib
+, pkg-config
+, protobuf
+, python
+, re2
+, stdenv
+, swig4
+, unzip
+, zlib
+}:
+
+stdenv.mkDerivation rec {
+  pname = "or-tools";
+  version = "9.4";
+
+  src = fetchFromGitHub {
+    owner = "google";
+    repo = "or-tools";
+    rev = "v${version}";
+    sha256 = "sha256-joWonJGuxlgHhXLznRhC1MDltQulXzpo4Do9dec1bLY=";
+  };
+  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=";
+    })
+    # 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
+  '';
+
+  cmakeFlags = [
+    "-DBUILD_DEPS=OFF"
+    "-DBUILD_PYTHON=ON"
+    "-DBUILD_pybind11=OFF"
+    "-DFETCH_PYTHON_DEPS=OFF"
+    "-DUSE_GLPK=ON"
+    "-DUSE_SCIP=OFF"
+    "-DPython3_EXECUTABLE=${python.pythonOnBuildForHost.interpreter}"
+  ] ++ lib.optionals stdenv.isDarwin [ "-DCMAKE_MACOSX_RPATH=OFF" ];
+  nativeBuildInputs = [
+    cmake
+    ensureNewerSourcesForZipFilesHook
+    pkg-config
+    python.pythonOnBuildForHost
+    swig4
+    unzip
+  ] ++ (with python.pythonOnBuildForHost.pkgs; [
+    pip
+    mypy-protobuf
+  ]);
+  buildInputs = [
+    bzip2
+    cbc
+    eigen
+    glpk
+    python.pkgs.absl-py
+    python.pkgs.pybind11
+    python.pkgs.setuptools
+    python.pkgs.wheel
+    re2
+    zlib
+  ];
+  propagatedBuildInputs = [
+    abseil-cpp
+    protobuf
+    (python.pkgs.protobuf.override { protobuf = protobuf; })
+    python.pkgs.numpy
+  ];
+  nativeCheckInputs = [
+    python.pkgs.matplotlib
+    python.pkgs.pandas
+    python.pkgs.virtualenv
+  ];
+
+  doCheck = true;
+
+  # This extra configure step prevents the installer from littering
+  # $out/bin with sample programs that only really function as tests,
+  # and disables the upstream installation of a zipped Python egg that
+  # can’t be imported with our Python setup.
+  installPhase = ''
+    cmake . -DBUILD_EXAMPLES=OFF -DBUILD_PYTHON=OFF -DBUILD_SAMPLES=OFF
+    cmake --install .
+    pip install --prefix="$python" python/
+  '';
+
+  outputs = [ "out" "python" ];
+
+  meta = with lib; {
+    homepage = "https://github.com/google/or-tools";
+    license = licenses.asl20;
+    description = ''
+      Google's software suite for combinatorial optimization.
+    '';
+    maintainers = with maintainers; [ andersk ];
+    platforms = with platforms; linux ++ darwin;
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/math/or-tools/fix-stringview-compile.patch b/nixpkgs/pkgs/development/libraries/science/math/or-tools/fix-stringview-compile.patch
new file mode 100644
index 000000000000..760ab80a38e4
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/math/or-tools/fix-stringview-compile.patch
@@ -0,0 +1,36 @@
+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/nixpkgs/pkgs/development/libraries/science/math/osi/default.nix b/nixpkgs/pkgs/development/libraries/science/math/osi/default.nix
new file mode 100644
index 000000000000..a6bc5a086251
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/math/osi/default.nix
@@ -0,0 +1,44 @@
+{ stdenv, lib, fetchFromGitHub, gfortran, pkg-config
+, blas, zlib, bzip2, coin-utils
+, withGurobi ? false, gurobi
+, withCplex ? false, cplex }:
+
+stdenv.mkDerivation rec {
+  pname = "osi";
+  version = "0.108.9";
+
+  src = fetchFromGitHub {
+    owner = "coin-or";
+    repo = "Osi";
+    rev = "releases/${version}";
+    hash = "sha256-ueIa9CL4K5ygKpkMRvfuWR0emEG6omg65ZKCsConWsw=";
+  };
+
+  buildInputs =
+    [ blas zlib bzip2 coin-utils ]
+    ++ lib.optional withGurobi gurobi
+    ++ lib.optional withCplex cplex;
+  nativeBuildInputs = [ gfortran pkg-config ];
+  configureFlags =
+    lib.optionals withGurobi [ "--with-gurobi-incdir=${gurobi}/include" "--with-gurobi-lib=-lgurobi${gurobi.libSuffix}" ]
+    ++ lib.optionals withCplex [ "--with-cplex-incdir=${cplex}/cplex/include/ilcplex" "--with-cplex-lib=-lcplex${cplex.libSuffix}" ];
+
+  NIX_LDFLAGS =
+    lib.optionalString withCplex "-L${cplex}/cplex/bin/${cplex.libArch}";
+
+  # Compile errors
+  env.NIX_CFLAGS_COMPILE = "-Wno-cast-qual";
+  hardeningDisable = [ "format" ];
+
+  enableParallelBuilding = true;
+
+  passthru = { inherit withGurobi withCplex; };
+
+  meta = with lib; {
+    description = "An abstract base class to a generic linear programming (LP) solver";
+    homepage = "https://github.com/coin-or/Osi";
+    license = licenses.epl20;
+    platforms = platforms.unix;
+    maintainers = with maintainers; [ abbradar ];
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/math/osqp/default.nix b/nixpkgs/pkgs/development/libraries/science/math/osqp/default.nix
new file mode 100644
index 000000000000..bf22e1d74d93
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/math/osqp/default.nix
@@ -0,0 +1,27 @@
+{ lib, stdenv
+, fetchFromGitHub
+, cmake
+}:
+
+stdenv.mkDerivation rec {
+  pname = "osqp";
+  version = "0.6.3";
+
+  src = fetchFromGitHub {
+    owner = "oxfordcontrol";
+    repo = "osqp";
+    rev = "v${version}";
+    sha256 = "sha256-enkK5EFyAeLaUnHNYS3oq43HsHY5IuSLgsYP0k/GW8c=";
+    fetchSubmodules = true;
+  };
+
+  nativeBuildInputs = [ cmake ];
+
+  meta = with lib; {
+    description = "A quadratic programming solver using operator splitting";
+    homepage = "https://osqp.org";
+    license = licenses.asl20;
+    maintainers = with maintainers; [ taktoa ];
+    platforms = platforms.all;
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/math/p4est-sc/default.nix b/nixpkgs/pkgs/development/libraries/science/math/p4est-sc/default.nix
new file mode 100644
index 000000000000..bb5d212061f2
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/math/p4est-sc/default.nix
@@ -0,0 +1,72 @@
+{ lib, stdenv, fetchFromGitHub, mpiCheckPhaseHook
+, autoreconfHook, pkg-config
+, p4est-sc-debugEnable ? true, p4est-sc-mpiSupport ? true
+, mpi, openssh, zlib
+}:
+
+let
+  dbg = lib.optionalString debugEnable "-dbg";
+  debugEnable = p4est-sc-debugEnable;
+  mpiSupport = p4est-sc-mpiSupport;
+  isOpenmpi = mpiSupport && mpi.pname == "openmpi";
+in
+stdenv.mkDerivation {
+  pname = "p4est-sc${dbg}";
+  version = "unstable-2021-06-14";
+
+  # fetch an untagged snapshot of the prev3-develop branch
+  src = fetchFromGitHub {
+    owner = "cburstedde";
+    repo = "libsc";
+    rev = "1ae814e3fb1cc5456652e0d77550386842cb9bfb";
+    sha256 = "14vm0b162jh8399pgpsikbwq4z5lkrw9vfzy3drqykw09n6nc53z";
+  };
+
+  strictDeps = true;
+  nativeBuildInputs = [ autoreconfHook pkg-config ];
+  propagatedNativeBuildInputs = lib.optional mpiSupport mpi
+    ++ lib.optional isOpenmpi openssh
+  ;
+  propagatedBuildInputs = [ zlib ];
+  inherit debugEnable mpiSupport;
+
+  postPatch = ''
+    echo "dist_scaclocal_DATA += config/sc_v4l2.m4" >> Makefile.am
+  '';
+  preConfigure = ''
+    echo "2.8.0" > .tarball-version
+    ${lib.optionalString mpiSupport "unset CC"}
+  '';
+
+  configureFlags = [ "--enable-pthread=-pthread" ]
+    ++ lib.optional debugEnable "--enable-debug"
+    ++ lib.optional mpiSupport "--enable-mpi"
+  ;
+
+  dontDisableStatic = true;
+  enableParallelBuilding = true;
+  makeFlags = [ "V=0" ];
+
+  nativeCheckInputs = lib.optionals mpiSupport [
+    mpiCheckPhaseHook
+    openssh
+  ];
+
+  # disallow Darwin checks due to prototype incompatibility of qsort_r
+  # to be fixed in a future version of the source code
+  doCheck = !stdenv.isDarwin && stdenv.hostPlatform == stdenv.buildPlatform;
+
+  meta = {
+    branch = "prev3-develop";
+    description = "Support for parallel scientific applications";
+    longDescription = ''
+      The SC library provides support for parallel scientific applications.
+      Its main purpose is to support the p4est software library, hence
+      this package is called p4est-sc, but it works standalone, too.
+    '';
+    homepage = "https://www.p4est.org/";
+    downloadPage = "https://github.com/cburstedde/libsc.git";
+    license = lib.licenses.lgpl21Plus;
+    maintainers = [ lib.maintainers.cburstedde ];
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/math/p4est/default.nix b/nixpkgs/pkgs/development/libraries/science/math/p4est/default.nix
new file mode 100644
index 000000000000..1218c695590e
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/math/p4est/default.nix
@@ -0,0 +1,64 @@
+{ lib
+, stdenv
+, fetchFromGitHub
+, autoreconfHook
+, pkg-config
+, p4est-withMetis ? true, metis
+, p4est-sc
+}:
+
+let
+  inherit (p4est-sc) debugEnable mpiSupport;
+  dbg = lib.optionalString debugEnable "-dbg";
+  withMetis = p4est-withMetis;
+in
+stdenv.mkDerivation {
+  pname = "p4est${dbg}";
+  version = "unstable-2021-06-22";
+
+  # fetch an untagged snapshot of the prev3-develop branch
+  src = fetchFromGitHub {
+    owner = "cburstedde";
+    repo = "p4est";
+    rev = "7423ac5f2b2b64490a7a92e5ddcbd251053c4dee";
+    sha256 = "0vffnf48rzw6d0as4c3x1f31b4kapmdzr1hfj5rz5ngah72gqrph";
+  };
+
+  strictDeps = true;
+  nativeBuildInputs = [ autoreconfHook pkg-config ];
+  propagatedBuildInputs = [ p4est-sc ];
+  buildInputs = lib.optional withMetis metis;
+  inherit debugEnable mpiSupport withMetis;
+
+  patches = [ ./p4est-metis.patch ];
+  postPatch = ''
+    sed -i -e "s:\(^\s*ACLOCAL_AMFLAGS.*\)\s@P4EST_SC_AMFLAGS@\s*$:\1 -I ${p4est-sc}/share/aclocal:" Makefile.am
+  '';
+  preAutoreconf = ''
+    echo "2.8.0" > .tarball-version
+  '';
+  preConfigure = lib.optionalString mpiSupport ''
+    unset CC
+  '';
+
+  configureFlags = p4est-sc.configureFlags
+    ++ [ "--with-sc=${p4est-sc}" ]
+    ++ lib.optional withMetis "--with-metis"
+  ;
+
+  inherit (p4est-sc) makeFlags dontDisableStatic enableParallelBuilding doCheck;
+
+  meta = {
+    branch = "prev3-develop";
+    description = "Parallel AMR on Forests of Octrees";
+    longDescription = ''
+      The p4est software library provides algorithms for parallel AMR.
+      AMR refers to Adaptive Mesh Refinement, a technique in scientific
+      computing to cover the domain of a simulation with an adaptive mesh.
+    '';
+    homepage = "https://www.p4est.org/";
+    downloadPage = "https://github.com/cburstedde/p4est.git";
+    license = lib.licenses.gpl2Plus;
+    maintainers = [ lib.maintainers.cburstedde ];
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/math/p4est/p4est-metis.patch b/nixpkgs/pkgs/development/libraries/science/math/p4est/p4est-metis.patch
new file mode 100644
index 000000000000..46b8dc8af08c
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/math/p4est/p4est-metis.patch
@@ -0,0 +1,26 @@
+diff --git a/src/p4est_connectivity.c b/src/p4est_connectivity.c
+index 95339136..c93528f2 100644
+--- a/src/p4est_connectivity.c
++++ b/src/p4est_connectivity.c
+@@ -3715,6 +3715,7 @@ p4est_connectivity_reorder_newid (sc_MPI_Comm comm, int k,
+                                   sc_array_t * newid)
+ {
+   const int           n = (int) conn->num_trees;
++  int                 metis_n;
+   int                *xadj;
+   int                *adjncy;
+   int                *part;
+@@ -3862,10 +3863,12 @@ p4est_connectivity_reorder_newid (sc_MPI_Comm comm, int k,
+ 
+     P4EST_GLOBAL_INFO ("Entering metis\n");
+     /* now call metis */
++    metis_n = n;
+     P4EST_EXECUTE_ASSERT_INT
+-      (METIS_PartGraphRecursive (&n, &ncon, xadj, adjncy, NULL, NULL,
++      (METIS_PartGraphRecursive (&metis_n, &ncon, xadj, adjncy, NULL, NULL,
+                                  NULL, &k, NULL, NULL, NULL, &volume, part),
+        METIS_OK);
++    P4EST_ASSERT (metis_n == n);
+     P4EST_GLOBAL_INFO ("Done metis\n");
+ 
+     P4EST_GLOBAL_STATISTICSF ("metis volume %d\n", volume);
diff --git a/nixpkgs/pkgs/development/libraries/science/math/parmetis/default.nix b/nixpkgs/pkgs/development/libraries/science/math/parmetis/default.nix
new file mode 100644
index 000000000000..db70bf8dd7a4
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/math/parmetis/default.nix
@@ -0,0 +1,34 @@
+{ lib, stdenv
+, fetchurl
+, cmake
+, mpi
+}:
+
+stdenv.mkDerivation rec {
+  pname = "parmetis";
+  version = "4.0.3";
+
+  src = fetchurl {
+    url = "http://glaros.dtc.umn.edu/gkhome/fetch/sw/parmetis/parmetis-${version}.tar.gz";
+    sha256 = "0pvfpvb36djvqlcc3lq7si0c5xpb2cqndjg8wvzg35ygnwqs5ngj";
+  };
+
+  nativeBuildInputs = [ cmake ];
+  buildInputs = [ mpi ];
+
+  # metis and GKlib are packaged with distribution
+  # AUR https://aur.archlinux.org/packages/parmetis/ has reported that
+  # it easier to build with the included packages as opposed to using the metis
+  # package. Compilation time is short.
+  configurePhase = ''
+    make config metis_path=$PWD/metis gklib_path=$PWD/metis/GKlib prefix=$out
+  '';
+
+  meta = with lib; {
+    description = "An MPI-based parallel library that implements a variety of algorithms for partitioning unstructured graphs, meshes, and for computing fill-reducing orderings of sparse matrices";
+    homepage = "http://glaros.dtc.umn.edu/gkhome/metis/parmetis/overview";
+    platforms = platforms.all;
+    license = licenses.unfree;
+    maintainers = [ maintainers.costrouc ];
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/math/petsc/default.nix b/nixpkgs/pkgs/development/libraries/science/math/petsc/default.nix
new file mode 100644
index 000000000000..c07250c660a3
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/math/petsc/default.nix
@@ -0,0 +1,96 @@
+{ 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/nixpkgs/pkgs/development/libraries/science/math/petsc/filter_mpi_warnings.patch b/nixpkgs/pkgs/development/libraries/science/math/petsc/filter_mpi_warnings.patch
new file mode 100644
index 000000000000..6a3c7bee051e
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/math/petsc/filter_mpi_warnings.patch
@@ -0,0 +1,100 @@
+diff --git a/src/snes/tutorials/makefile b/src/snes/tutorials/makefile
+index 168febb34b6..71068469066 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 opendir(\/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 opendir(\/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 opendir(\/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 opendir(\/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 opendir(\/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 opendir(\/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 opendir(\/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 opendir(\/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 opendir(\/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 opendir(\/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 opendir(\/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 opendir(\/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/nixpkgs/pkgs/development/libraries/science/math/planarity/default.nix b/nixpkgs/pkgs/development/libraries/science/math/planarity/default.nix
new file mode 100644
index 000000000000..3b072fecde34
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/math/planarity/default.nix
@@ -0,0 +1,30 @@
+{ lib, stdenv
+, fetchFromGitHub
+, autoreconfHook
+}:
+
+stdenv.mkDerivation rec {
+  pname = "planarity";
+  version = "3.0.2.0";
+
+  src = fetchFromGitHub {
+    owner = "graph-algorithms";
+    repo = "edge-addition-planarity-suite";
+    rev = "Version_${version}";
+    sha256 = "sha256-cUAh2MXCSmtxFtV6iTHgSRgsq/26DjWwxhWJH1+367A=";
+  };
+
+  nativeBuildInputs = [
+    autoreconfHook
+  ];
+
+  doCheck = true;
+
+  meta = with lib; {
+    homepage = "https://github.com/graph-algorithms/edge-addition-planarity-suite";
+    description = "A library for implementing graph algorithms";
+    license = licenses.bsd3;
+    maintainers = teams.sage.members;
+    platforms = platforms.unix;
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/math/rankwidth/default.nix b/nixpkgs/pkgs/development/libraries/science/math/rankwidth/default.nix
new file mode 100644
index 000000000000..c00d579702cc
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/math/rankwidth/default.nix
@@ -0,0 +1,27 @@
+{ lib, stdenv
+, fetchurl
+}:
+
+stdenv.mkDerivation rec {
+  pname = "rankwidth";
+  version = "0.9";
+
+  src = fetchurl {
+    url = "mirror://sageupstream/rw/rw-${version}.tar.gz";
+    sha256 = "sha256-weA1Bv4lzfy0KMBR/Fay0q/7Wwb7o/LOdWYxRmvvtEE=";
+  };
+
+  configureFlags = [
+    "--enable-executable=no" # no igraph dependency
+  ];
+
+  # check phase is empty for now (as of version 0.9)
+  doCheck = true;
+
+  meta = with lib; {
+    description = "Calculates rank-width and rank-decompositions";
+    license = with licenses; [ gpl2Plus ];
+    maintainers = teams.sage.members;
+    platforms = platforms.unix;
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/math/rubiks/default.nix b/nixpkgs/pkgs/development/libraries/science/math/rubiks/default.nix
new file mode 100644
index 000000000000..505457edd64f
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/math/rubiks/default.nix
@@ -0,0 +1,81 @@
+{ lib, stdenv
+, fetchurl
+, fetchpatch
+, coreutils
+}:
+
+stdenv.mkDerivation rec {
+  pname = "rubiks";
+  version = "20070912";
+
+  src = fetchurl {
+    url = "mirror://sageupstream/rubiks/rubiks-${version}.tar.bz2";
+    sha256 = "0zdmkb0j1kyspdpsszzb2k3279xij79jkx0dxd9f3ix1yyyg3yfq";
+  };
+
+  preConfigure = ''
+    export INSTALL="${coreutils}/bin/install"
+  '';
+
+  # everything is done in `make install`
+  buildPhase = "true";
+
+  installFlags = [
+    "PREFIX=$(out)"
+  ];
+
+  patches = [
+    # Fix makefiles which use all the variables in all the wrong ways and
+    # hardcode values for some variables.
+    (fetchpatch {
+      url = "https://raw.githubusercontent.com/sagemath/sage/07d6c37d18811e2b377a9689790a7c5e24da16ba/build/pkgs/rubiks/patches/dietz-cu2-Makefile.patch";
+      sha256 = "1ry3w1mk9q4jqd91zlaa1bdiiplld4hpfjaldbhlmzlgrrc99qmq";
+    })
+    (fetchpatch {
+      url = "https://raw.githubusercontent.com/sagemath/sage/07d6c37d18811e2b377a9689790a7c5e24da16ba/build/pkgs/rubiks/patches/dietz-mcube-Makefile.patch";
+      sha256 = "0zsbh6k3kqdg82fv0kzghr1x7pafisv943gmssqscp107bhg77bz";
+    })
+    (fetchpatch {
+      url = "https://raw.githubusercontent.com/sagemath/sage/07d6c37d18811e2b377a9689790a7c5e24da16ba/build/pkgs/rubiks/patches/dietz-solver-Makefile.patch";
+      sha256 = "0vhw70ylnmydgjhwx8jjlb2slccj4pfqn6vzirkyz1wp8apsmfhp";
+    })
+    (fetchpatch {
+      url = "https://raw.githubusercontent.com/sagemath/sage/07d6c37d18811e2b377a9689790a7c5e24da16ba/build/pkgs/rubiks/patches/reid-Makefile.patch";
+      sha256 = "1r311sn012xs135s0d21qwsig2kld7rdcq19nm0zbnklviid57df";
+    })
+  ];
+
+  meta = with lib; {
+    homepage = "https://wiki.sagemath.org/spkg/rubiks";
+    description = "Several programs for working with Rubik's cubes";
+    # The individual websites are no longer available
+    longDescription = ''
+      There are several programs for working with Rubik's cubes, by three
+      different people. Look inside the directories under /src to see
+      specific info and licensing. In summary the three contributers are:
+
+
+      Michael Reid (GPL) http://www.math.ucf.edu/~reid/Rubik/optimal_solver.html
+          optimal - uses many pre-computed tables to find an optimal
+                    solution to the 3x3x3 Rubik's cube
+
+
+      Dik T. Winter (MIT License)
+          cube    - uses Kociemba's algorithm to iteratively find a short
+                    solution to the 3x3x3 Rubik's cube
+          size222 - solves a 2x2x2 Rubik's cube
+
+
+      Eric Dietz (GPL) http://www.wrongway.org/?rubiksource
+          cu2   - A fast, non-optimal 2x2x2 solver
+          cubex - A fast, non-optimal 3x3x3 solver
+          mcube - A fast, non-optimal 4x4x4 solver
+    '';
+    license = with licenses; [
+      gpl2 # Michael Reid's and Eric Dietz software
+      mit # Dik T. Winter's software
+    ];
+    maintainers = teams.sage.members;
+    platforms = platforms.unix;
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/math/scalapack/default.nix b/nixpkgs/pkgs/development/libraries/science/math/scalapack/default.nix
new file mode 100644
index 000000000000..85aa5c4a8736
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/math/scalapack/default.nix
@@ -0,0 +1,75 @@
+{ lib, stdenv, fetchFromGitHub, fetchpatch, cmake
+, openssh, mpiCheckPhaseHook, mpi, blas, lapack
+} :
+
+assert blas.isILP64 == lapack.isILP64;
+
+stdenv.mkDerivation rec {
+  pname = "scalapack";
+  version = "2.2.1";
+
+  src = fetchFromGitHub {
+    owner = "Reference-ScaLAPACK";
+    repo = pname;
+    rev = "v${version}";
+    sha256 = "sha256-GNVGWrIWdfyTfbz7c31Vjt9eDlVzCd/aLHoWq2DMyX4=";
+  };
+
+  passthru = { inherit (blas) isILP64; };
+
+  # upstream patch, remove with next release
+  patches = [ (fetchpatch {
+    name = "gcc-10";
+    url = "https://github.com/Reference-ScaLAPACK/scalapack/commit/a0f76fc0c1c16646875b454b7d6f8d9d17726b5a.patch";
+    sha256 = "0civn149ikghakic30bynqg1bal097hr7i12cm4kq3ssrhq073bp";
+  })];
+
+  # Required to activate ILP64.
+  # See https://github.com/Reference-ScaLAPACK/scalapack/pull/19
+  postPatch = lib.optionalString passthru.isILP64 ''
+    sed -i 's/INTSZ = 4/INTSZ = 8/g'   TESTING/EIG/* TESTING/LIN/*
+    sed -i 's/INTGSZ = 4/INTGSZ = 8/g' TESTING/EIG/* TESTING/LIN/*
+
+    # These tests are not adapted to ILP64
+    sed -i '/xssep/d;/xsgsep/d;/xssyevr/d' TESTING/CMakeLists.txt
+  '';
+
+  outputs = [ "out" "dev" ];
+
+  nativeBuildInputs = [ cmake ];
+  nativeCheckInputs = [ openssh mpiCheckPhaseHook ];
+  buildInputs = [ blas lapack ];
+  propagatedBuildInputs = [ mpi ];
+  hardeningDisable = lib.optionals (stdenv.isAarch64 && stdenv.isDarwin) [ "stackprotector" ];
+
+  # xslu and xsllt tests seem to time out on x86_64-darwin.
+  # this line is left so those who force installation on x86_64-darwin can still build
+  doCheck = !(stdenv.isx86_64 && stdenv.isDarwin);
+
+  preConfigure = ''
+    cmakeFlagsArray+=(
+      -DBUILD_SHARED_LIBS=ON -DBUILD_STATIC_LIBS=OFF
+      -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"
+      ''}
+      )
+  '';
+
+  # Increase individual test timeout from 1500s to 10000s because hydra's builds
+  # sometimes fail due to this
+  checkFlagsArray = [ "ARGS=--timeout 10000" ];
+
+  meta = with lib; {
+    homepage = "http://www.netlib.org/scalapack/";
+    description = "Library of high-performance linear algebra routines for parallel distributed memory machines";
+    license = licenses.bsd3;
+    platforms = platforms.unix;
+    maintainers = with maintainers; [ costrouc markuskowa gdinh ];
+    # xslu and xsllt tests fail on x86 darwin
+    broken = stdenv.isDarwin && stdenv.isx86_64;
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/math/scs/default.nix b/nixpkgs/pkgs/development/libraries/science/math/scs/default.nix
new file mode 100644
index 000000000000..087f4787a53b
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/math/scs/default.nix
@@ -0,0 +1,52 @@
+{ lib, stdenv, fetchFromGitHub, blas, lapack, gfortran, fixDarwinDylibNames }:
+
+assert (!blas.isILP64) && (!lapack.isILP64);
+
+stdenv.mkDerivation rec {
+  pname = "scs";
+  version = "3.2.3";
+
+  src = fetchFromGitHub {
+    owner = "cvxgrp";
+    repo = "scs";
+    rev = version;
+    sha256 = "sha256-0g0r3DNgkPZgag0qtz79Wk3Cre1I2yaabFi3OgUzgfc=";
+  };
+
+  # Actually link and add libgfortran to the rpath
+  postPatch = ''
+    substituteInPlace scs.mk \
+      --replace "#-lgfortran" "-lgfortran" \
+      --replace "gcc" "cc"
+  '';
+
+  nativeBuildInputs = lib.optional stdenv.isDarwin fixDarwinDylibNames;
+
+  buildInputs = [ blas lapack gfortran.cc.lib ];
+
+  doCheck = true;
+
+  # Test demo requires passing data and seed; numbers chosen arbitrarily.
+  postCheck = ''
+    ./out/demo_socp_indirect 42 0.42 0.42 42
+  '';
+
+  installPhase = ''
+    runHook preInstall
+    mkdir -p $out/lib
+    cp -r include $out/
+    cp out/*.a out/*.so out/*.dylib $out/lib/
+    runHook postInstall
+  '';
+
+  meta = with lib; {
+    description = "Splitting Conic Solver";
+    longDescription = ''
+      Numerical optimization package for solving large-scale convex cone problems
+    '';
+    homepage = "https://github.com/cvxgrp/scs";
+    license = licenses.mit;
+    platforms = platforms.all;
+    maintainers = [ maintainers.bhipple ];
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/math/spooles/allocate.patch b/nixpkgs/pkgs/development/libraries/science/math/spooles/allocate.patch
new file mode 100644
index 000000000000..71f539711e7b
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/math/spooles/allocate.patch
@@ -0,0 +1,38 @@
+From cc153b180829c6b561765cbbb9b621d1142ff1cd Mon Sep 17 00:00:00 2001
+From: annalee <150648636+a-n-n-a-l-e-e@users.noreply.github.com>
+Date: Tue, 28 Nov 2023 13:13:44 +0000
+Subject: [PATCH] use proper format specifier for size_t
+
+---
+ Utilities/MM.h | 6 +++---
+ 1 file changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/Utilities/MM.h b/Utilities/MM.h
+index 11e86c5..301c3ec 100644
+--- a/Utilities/MM.h
++++ b/Utilities/MM.h
+@@ -33,18 +33,18 @@ if ( (count) > 0 ) { \
+    if ( (ptr = (type *)malloc((unsigned long)((count)*sizeof(type)))) \
+         == NULL ) {\
+       fprintf(stderr, \
+-              "\n ALLOCATE failure : bytes %d, line %d, file %s", \
++              "\n ALLOCATE failure : bytes %zu, line %d, file %s", \
+               (count)*sizeof(type), __LINE__, __FILE__) ; \
+       exit(-1) ; } \
+    else if ( MEMORY_DEBUG > 0 ) { \
+       fprintf(stderr, \
+-              "\n ALLOCATE : address %p, bytes %d, line %d, file %s", \
++              "\n ALLOCATE : address %p, bytes %zu, line %d, file %s", \
+               ptr, (count)*sizeof(type), __LINE__, __FILE__) ; } } \
+ else if ( (count) == 0 ) { \
+    ptr = NULL ; } \
+ else { \
+    fprintf(stderr, \
+-           "\n ALLOCATE error : bytes %d, line %d, file %s", \
++           "\n ALLOCATE error : bytes %zu, line %d, file %s", \
+            (count)*sizeof(type), __LINE__, __FILE__) ; \
+    exit(-1) ; }
+ /*
+-- 
+2.42.0
+
diff --git a/nixpkgs/pkgs/development/libraries/science/math/spooles/default.nix b/nixpkgs/pkgs/development/libraries/science/math/spooles/default.nix
new file mode 100644
index 000000000000..47738008b02d
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/math/spooles/default.nix
@@ -0,0 +1,56 @@
+{ lib, stdenv, fetchurl, perl }:
+
+stdenv.mkDerivation rec {
+  pname = "spooles";
+  version = "2.2";
+
+  src = fetchurl {
+    url = "http://www.netlib.org/linalg/spooles/spooles.${version}.tgz";
+    sha256 = "1pf5z3vvwd8smbpibyabprdvcmax0grzvx2y0liy98c7x6h5jid8";
+  };
+
+  sourceRoot = ".";
+
+  patches = [
+    ./spooles.patch
+    # fix compiler error where NULL is used as a zero parameter
+    ./transform.patch
+    # use proper format specifier for size_t
+    ./allocate.patch
+  ];
+
+  postPatch = lib.optionalString stdenv.hostPlatform.isDarwin ''
+    substituteInPlace makefile --replace "-Wl,-soname," "-Wl,-install_name,$out/lib/"
+  '';
+
+  buildPhase = ''
+    make lib
+  '';
+
+  installPhase = ''
+    mkdir -p $out/lib $out/include/spooles
+    cp libspooles.a libspooles.so.2.2 $out/lib/
+    ln -s libspooles.so.2.2 $out/lib/libspooles.so.2
+    ln -s libspooles.so.2 $out/lib/libspooles.so
+    for h in *.h; do
+      if [ $h != 'MPI.h' ]; then
+         cp $h $out/include/spooles
+         d=`basename $h .h`
+         if [ -d $d ]; then
+            mkdir $out/include/spooles/$d
+            cp $d/*.h $out/include/spooles/$d
+         fi
+      fi
+    done
+  '';
+
+  nativeBuildInputs = [ perl ];
+
+  meta = with lib; {
+    homepage = "http://www.netlib.org/linalg/spooles/";
+    description = "Library for solving sparse real and complex linear systems of equations";
+    license = licenses.publicDomain;
+    maintainers = with maintainers; [ gebner ];
+    platforms = platforms.unix;
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/math/spooles/spooles.patch b/nixpkgs/pkgs/development/libraries/science/math/spooles/spooles.patch
new file mode 100644
index 000000000000..71fb4a7f44e1
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/math/spooles/spooles.patch
@@ -0,0 +1,188 @@
+diff --git a/I2Ohash/src/util.c b/I2Ohash/src/util.c
+index 72d082e..f32f667 100644
+--- a/I2Ohash/src/util.c
++++ b/I2Ohash/src/util.c
+@@ -39,9 +39,10 @@ fflush(stdout) ;
+ */
+ loc1 = (key1 + 1) % hashtable->nlist ;
+ loc2 = (key2 + 1) % hashtable->nlist ;
+-loc  = (loc1*loc2) % hashtable->nlist ;
++long int loc3  = (long int)loc1*(long int)loc2 % hashtable->nlist ;
++loc =(int) loc3;
+ #if MYDEBUG > 0
+-fprintf(stdout, "\n loc1 = %d, loc2 = %d, loc3 = %d", loc1, loc2, loc) ;
++fprintf(stdout, "\n loc1 = %d, loc2 = %d, loc3 = %ld, loc = %d", loc1, loc2, loc3, loc) ;
+ fflush(stdout) ;
+ #endif
+ /*
+@@ -158,9 +159,10 @@ fflush(stdout) ;
+ #endif
+ loc1 = (key1 + 1) % hashtable->nlist ;
+ loc2 = (key2 + 1) % hashtable->nlist ;
+-loc  = (loc1*loc2) % hashtable->nlist ;
++long int loc3  = (long int)loc1*(long int)loc2 % hashtable->nlist ;
++loc =(int) loc3;
+ #if MYDEBUG > 0
+-fprintf(stdout, "\n loc1 = %d, loc2 = %d, loc3 = %d", loc1, loc2, loc) ;
++fprintf(stdout, "\n loc1 = %d, loc2 = %d, loc3 = %ld, loc = %d", loc1, loc2, loc3, loc) ;
+ fflush(stdout) ;
+ #endif
+ /*
+diff --git a/MPI/makefile b/MPI/makefile
+index 0c09f86..d25e70a 100644
+--- a/MPI/makefile
++++ b/MPI/makefile
+@@ -2,7 +2,7 @@ all_drivers :
+ 	cd drivers ; make drivers
+ 
+ lib :
+-	cd src ; make spoolesMPI.a
++	cd src ; make makeLib
+ 
+ clean :
+ 	cd src ; make clean
+diff --git a/MPI/src/makefile b/MPI/src/makefile
+index f7650b7..71e4c49 100644
+--- a/MPI/src/makefile
++++ b/MPI/src/makefile
+@@ -42,3 +42,8 @@ $(OBJ).a : \
+ 
+ clean :
+ 	- rm -f *.a *.o
++
++makeLib :
++	perl ../../makeLib > makeG
++	make -f makeG
++	rm -f makeG
+diff --git a/MT/makefile b/MT/makefile
+index 9b86a32..d25e70a 100644
+--- a/MT/makefile
++++ b/MT/makefile
+@@ -2,7 +2,7 @@ all_drivers :
+ 	cd drivers ; make drivers
+ 
+ lib :
+-	cd src ; make spoolesMT.a
++	cd src ; make makeLib
+ 
+ clean :
+ 	cd src ; make clean
+diff --git a/Make.inc b/Make.inc
+index f99eb8f..2de8a25 100644
+--- a/Make.inc
++++ b/Make.inc
+@@ -12,7 +12,7 @@
+ # for solaris
+ #
+ # CC = gcc
+-  CC = /usr/lang-4.0/bin/cc
++#  CC = /usr/lang-4.0/bin/cc
+ #
+ # for sgi
+ #
+@@ -28,7 +28,7 @@
+ # 
+ # OPTLEVEL = 
+ # OPTLEVEL = -g -v
+-  OPTLEVEL = -O
++  OPTLEVEL = -O3
+ # OPTLEVEL = -xO5 -v
+ # OPTLEVEL = -O3
+ # OPTLEVEL = -O4
+@@ -43,7 +43,7 @@
+ #  set any load flags
+ #
+ #  LDFLAGS = -Wl,+parallel -Wl,+tm,spp2000 # for hp exemplar
+-   LDFLAGS =
++#   LDFLAGS =
+ #
+ #---------------------------------------------------------------------
+ #
+@@ -103,7 +103,7 @@
+ #  MPI install library
+ #
+ # MPI_INSTALL_DIR = 
+-  MPI_INSTALL_DIR = /usr/local/mpich-1.0.13
++#  MPI_INSTALL_DIR = /usr/lib/openmpi
+ #
+ #---------------------------------------------------------------------
+ #
+@@ -142,6 +142,6 @@
+ #  MPI include path
+ #
+ # MPI_INCLUDE_DIR = 
+-  MPI_INCLUDE_DIR = -I$(MPI_INSTALL_DIR)/include
++#  MPI_INCLUDE_DIR = -I/usr/include/mpi
+ #
+ #---------------------------------------------------------------------
+diff --git a/Utilities/src/iohb.c b/Utilities/src/iohb.c
+index ac38f7b..ac34034 100644
+--- a/Utilities/src/iohb.c
++++ b/Utilities/src/iohb.c
+@@ -1725,7 +1725,7 @@ static void upcase(char* S)
+ 
+ static void IOHBTerminate(char* message) 
+ {
+-   fprintf(stderr,message);
++   fputs(message, stderr);
+    exit(1);
+ }
+ 
+diff --git a/makeLib b/makeLib
+index 1780f39..7697b06 100755
+--- a/makeLib
++++ b/makeLib
+@@ -64,14 +64,19 @@ foreach $src ( @srcnames ) {
+    $srcname = " \\\n     " . $src ;
+    print $srcname ;
+ }
++print "\n\n.SUFFIXES: .c .o .lo .a .so" ;
+ print "\n\nOBJ_FILES = \$\{SRC:.c=.o\}" ;
++print "\n\nLOBJ_FILES = \$\{SRC:.c=.lo\}" ;
+ print "\n\n" ;
+ print <<'EOF' ;
+ .c.o :
+-	$(PURIFY) $(CC) -c $(CFLAGS) $*.c -o $(OBJ)_$*.o
++	$(PURIFY) $(CC) -c $(CFLAGS) $*.c -o $(OBJ)_$*.o $(MPI_INCLUDE_DIR)
+ 
+-../../spooles.a : ${OBJ_FILES}
+-	$(AR) $(ARFLAGS) ../../spooles.a $(OBJ)_*.o
++.c.lo :
++	$(PURIFY) $(CC) -c $(CFLAGS) $*.c -fPIC -DPIC -o $(OBJ)_$*.lo $(MPI_INCLUDE_DIR)
++
++../../libspooles.a : ${OBJ_FILES} ${LOBJ_FILES}
++	$(AR) $(ARFLAGS) ../../libspooles.a $(OBJ)_*.o
+ 	rm -f $(OBJ)_*.o
+-	$(RANLIB) ../../spooles.a
++	$(RANLIB) ../../libspooles.a
+ EOF
+diff --git a/makefile b/makefile
+index f014c7d..7c8042a 100755
+--- a/makefile
++++ b/makefile
+@@ -124,7 +124,9 @@ lib :
+ 	cd ZV               ; make lib
+ 	cd misc             ; make lib
+ #cd MPI              ; make lib
+-#cd MT               ; make lib
++	cd MT               ; make lib
++	$(CC) -shared */*/*.lo -Wl,-soname,libspooles.so.2.2 -o libspooles.so.2.2 -lpthread -lm
++	ln -s libspooles.so.2.2 libspooles.so
+ 
+ global :
+ 	cd A2/src             ; make -f makeGlobalLib
+diff --git a/timings.h b/timings.h
+index 23df189..685800b 100644
+--- a/timings.h
++++ b/timings.h
+@@ -2,9 +2,8 @@
+ #define _TIMINGS_
+ #include <sys/time.h>
+ static struct timeval  TV ;
+-static struct timezone TZ ;
+ #define MARKTIME(t) \
+-   gettimeofday(&TV, &TZ) ; \
++   gettimeofday(&TV, NULL) ; \
+    t = (TV.tv_sec + 0.000001*TV.tv_usec)
+ #endif
+ 
diff --git a/nixpkgs/pkgs/development/libraries/science/math/spooles/transform.patch b/nixpkgs/pkgs/development/libraries/science/math/spooles/transform.patch
new file mode 100644
index 000000000000..3be3babe9d65
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/math/spooles/transform.patch
@@ -0,0 +1,43 @@
+From c5d0574182d76af3bf286dce0bb147ae3f098916 Mon Sep 17 00:00:00 2001
+From: annalee <150648636+a-n-n-a-l-e-e@users.noreply.github.com>
+Date: Tue, 28 Nov 2023 12:57:18 +0000
+Subject: [PATCH] fix compiler error: use zero, not NULL, in calls to IVinit
+
+---
+ ETree/src/transform.c | 6 +++---
+ 1 file changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/ETree/src/transform.c b/ETree/src/transform.c
+index 1e36981..dbdfc70 100644
+--- a/ETree/src/transform.c
++++ b/ETree/src/transform.c
+@@ -291,7 +291,7 @@ etree2 = ETree_compress(etree, mapIV) ;
+    remap the nzeros[] vector
+    -------------------------
+ */
+-temp = IVinit(nfront, NULL) ;
++temp = IVinit(nfront, 0) ;
+ IVcopy(nfront, temp, nzeros) ;
+ IV_setSize(nzerosIV, nnew) ;
+ nzeros = IV_entries(nzerosIV) ;
+@@ -453,7 +453,7 @@ etree2 = ETree_compress(etree, mapIV) ;
+    remap the nzeros[] vector
+    -------------------------
+ */
+-temp = IVinit(nfront, NULL) ;
++temp = IVinit(nfront, 0) ;
+ IVcopy(nfront, temp, nzeros) ;
+ IV_setSize(nzerosIV, nnew) ;
+ nzeros = IV_entries(nzerosIV) ;
+@@ -614,7 +614,7 @@ etree2 = ETree_compress(etree, mapIV) ;
+    remap the nzeros[] vector
+    -------------------------
+ */
+-temp = IVinit(nfront, NULL) ;
++temp = IVinit(nfront, 0) ;
+ IVcopy(nfront, temp, nzeros) ;
+ IV_setSize(nzerosIV, nnew) ;
+ nzeros = IV_entries(nzerosIV) ;
+-- 
+2.42.0
+
diff --git a/nixpkgs/pkgs/development/libraries/science/math/suitesparse-graphblas/default.nix b/nixpkgs/pkgs/development/libraries/science/math/suitesparse-graphblas/default.nix
new file mode 100644
index 000000000000..ac08cb876253
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/math/suitesparse-graphblas/default.nix
@@ -0,0 +1,37 @@
+{ lib
+, stdenv
+, fetchFromGitHub
+, cmake
+, gnum4
+}:
+
+stdenv.mkDerivation rec {
+  pname = "suitesparse-graphblas";
+  version = "9.0.3";
+
+  outputs = [ "out" "dev" ];
+
+  src = fetchFromGitHub {
+    owner = "DrTimothyAldenDavis";
+    repo = "GraphBLAS";
+    rev = "v${version}";
+    hash = "sha256-qRRrxMshLLEltCzXFv/j6NgRi6x1SHlAuKG5NfLiBFs=";
+  };
+
+  nativeBuildInputs = [
+    cmake
+    gnum4
+  ];
+
+  preConfigure = ''
+    export HOME=$(mktemp -d)
+  '';
+
+  meta = with lib; {
+    description = "Graph algorithms in the language of linear algebra";
+    homepage = "https://people.engr.tamu.edu/davis/GraphBLAS.html";
+    license = licenses.asl20;
+    maintainers = with maintainers; [ wegank ];
+    platforms = with platforms; unix;
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/math/suitesparse/4.2.nix b/nixpkgs/pkgs/development/libraries/science/math/suitesparse/4.2.nix
new file mode 100644
index 000000000000..b8ce3eca888c
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/math/suitesparse/4.2.nix
@@ -0,0 +1,43 @@
+{ lib, stdenv, fetchurl, gfortran, blas, lapack }:
+
+let
+  int_t = if blas.isILP64 then "int64_t" else "int32_t";
+in
+stdenv.mkDerivation rec {
+  version = "4.2.1";
+  pname = "suitesparse";
+  src = fetchurl {
+    url = "http://www.cise.ufl.edu/research/sparse/SuiteSparse/SuiteSparse-${version}.tar.gz" ;
+    sha256 = "1ga69637x7kdkiy3w3lq9dvva7220bdangv2lch2wx1hpi83h0p8";
+  };
+
+  nativeBuildInputs = [ gfortran ];
+  buildInputs = [ blas lapack ];
+
+  preConfigure = ''
+    mkdir -p $out/lib
+    mkdir -p $out/include
+
+    sed -i "SuiteSparse_config/SuiteSparse_config.mk" \
+        -e 's/METIS .*$/METIS =/' \
+        -e 's/METIS_PATH .*$/METIS_PATH =/' \
+        -e '/CHOLMOD_CONFIG/ s/$/-DNPARTITION -DLONGBLAS=${int_t}/' \
+        -e '/UMFPACK_CONFIG/ s/$/-DLONGBLAS=${int_t}/'
+  '';
+
+  makeFlags = [
+    "PREFIX=\"$(out)\""
+    "INSTALL_LIB=$(out)/lib"
+    "INSTALL_INCLUDE=$(out)/include"
+    "BLAS=-lblas"
+    "LAPACK=-llapack"
+  ];
+
+  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;
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/math/suitesparse/4.4.nix b/nixpkgs/pkgs/development/libraries/science/math/suitesparse/4.4.nix
new file mode 100644
index 000000000000..cbc24b154656
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/math/suitesparse/4.4.nix
@@ -0,0 +1,99 @@
+{ lib, stdenv, fetchurl, gfortran, blas, lapack
+, config
+, enableCuda ? config.cudaSupport, cudatoolkit
+}:
+
+let
+  int_t = if blas.isILP64 then "int64_t" else "int32_t";
+  SHLIB_EXT = stdenv.hostPlatform.extensions.sharedLibrary;
+in
+stdenv.mkDerivation rec {
+  version = "4.4.4";
+  pname = "suitesparse";
+
+  src = fetchurl {
+    url = "http://faculty.cse.tamu.edu/davis/SuiteSparse/SuiteSparse-${version}.tar.gz";
+    sha256 = "1zdn1y0ij6amj7smmcslkqgbqv9yy5cwmbyzqc9v6drzdzllgbpj";
+  };
+
+  preConfigure = ''
+    mkdir -p $out/lib
+    mkdir -p $out/include
+
+    sed -i "SuiteSparse_config/SuiteSparse_config.mk" \
+        -e 's/METIS .*$/METIS =/' \
+        -e 's/METIS_PATH .*$/METIS_PATH =/' \
+        -e '/CHOLMOD_CONFIG/ s/$/-DNPARTITION -DLONGBLAS=${int_t}/' \
+        -e '/UMFPACK_CONFIG/ s/$/-DLONGBLAS=${int_t}/'
+  ''
+  + lib.optionalString stdenv.isDarwin ''
+    sed -i "SuiteSparse_config/SuiteSparse_config.mk" \
+        -e 's/^[[:space:]]*\(LIB = -lm\) -lrt/\1/'
+  ''
+  + lib.optionalString enableCuda ''
+    sed -i "SuiteSparse_config/SuiteSparse_config.mk" \
+        -e 's|^[[:space:]]*\(CUDA_ROOT     =\)|CUDA_ROOT = ${cudatoolkit}|' \
+        -e 's|^[[:space:]]*\(GPU_BLAS_PATH =\)|GPU_BLAS_PATH = $(CUDA_ROOT)|' \
+        -e 's|^[[:space:]]*\(GPU_CONFIG    =\)|GPU_CONFIG = -I$(CUDA_ROOT)/include -DGPU_BLAS -DCHOLMOD_OMP_NUM_THREADS=$(NIX_BUILD_CORES) |' \
+        -e 's|^[[:space:]]*\(CUDA_PATH     =\)|CUDA_PATH = $(CUDA_ROOT)|' \
+        -e 's|^[[:space:]]*\(CUDART_LIB    =\)|CUDART_LIB = $(CUDA_ROOT)/lib64/libcudart.so|' \
+        -e 's|^[[:space:]]*\(CUBLAS_LIB    =\)|CUBLAS_LIB = $(CUDA_ROOT)/lib64/libcublas.so|' \
+        -e 's|^[[:space:]]*\(CUDA_INC_PATH =\)|CUDA_INC_PATH = $(CUDA_ROOT)/include/|' \
+        -e 's|^[[:space:]]*\(NV20          =\)|NV20 = -arch=sm_20 -Xcompiler -fPIC|' \
+        -e 's|^[[:space:]]*\(NV30          =\)|NV30 = -arch=sm_30 -Xcompiler -fPIC|' \
+        -e 's|^[[:space:]]*\(NV35          =\)|NV35 = -arch=sm_35 -Xcompiler -fPIC|' \
+        -e 's|^[[:space:]]*\(NVCC          =\) echo|NVCC = $(CUDA_ROOT)/bin/nvcc|' \
+        -e 's|^[[:space:]]*\(NVCCFLAGS     =\)|NVCCFLAGS = $(NV20) -O3 -gencode=arch=compute_20,code=sm_20 -gencode=arch=compute_30,code=sm_30 -gencode=arch=compute_35,code=sm_35 -gencode=arch=compute_60,code=sm_60|'
+  '';
+
+  makeFlags = [
+    "PREFIX=\"$(out)\""
+    "INSTALL_LIB=$(out)/lib"
+    "INSTALL_INCLUDE=$(out)/include"
+    "BLAS=-lblas"
+    "LAPACK=-llapack"
+  ];
+
+  env.NIX_CFLAGS_COMPILE = lib.optionalString stdenv.isDarwin " -DNTIMER";
+
+  postInstall = ''
+    # Build and install shared library
+    (
+        cd "$(mktemp -d)"
+        for i in "$out"/lib/lib*.a; do
+          ar -x $i
+        done
+        ${if enableCuda then cudatoolkit else stdenv.cc.outPath}/bin/${if enableCuda then "nvcc" else "cc"} *.o ${if stdenv.isDarwin then "-dynamiclib" else "--shared"} -o "$out/lib/libsuitesparse${SHLIB_EXT}" -lblas ${lib.optionalString enableCuda "-lcublas"}
+    )
+    for i in umfpack cholmod amd camd colamd spqr; do
+      ln -s libsuitesparse${SHLIB_EXT} "$out"/lib/lib$i${SHLIB_EXT}
+    done
+
+    # Install documentation
+    outdoc=$out/share/doc/suitesparse-${version}
+    mkdir -p $outdoc
+    cp -r AMD/Doc $outdoc/amd
+    cp -r BTF/Doc $outdoc/bft
+    cp -r CAMD/Doc $outdoc/camd
+    cp -r CCOLAMD/Doc $outdoc/ccolamd
+    cp -r CHOLMOD/Doc $outdoc/cholmod
+    cp -r COLAMD/Doc $outdoc/colamd
+    cp -r CXSparse/Doc $outdoc/cxsparse
+    cp -r KLU/Doc $outdoc/klu
+    cp -r LDL/Doc $outdoc/ldl
+    cp -r RBio/Doc $outdoc/rbio
+    cp -r SPQR/Doc $outdoc/spqr
+    cp -r UMFPACK/Doc $outdoc/umfpack
+  '';
+
+  nativeBuildInputs = [ gfortran ];
+  buildInputs = [ blas lapack ];
+
+  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;
+  };
+}
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..9561cf2ed779
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/math/suitesparse/default.nix
@@ -0,0 +1,94 @@
+{ lib, stdenv
+, fetchFromGitHub
+, gfortran
+, blas, lapack
+, metis
+, fixDarwinDylibNames
+, gmp
+, mpfr
+, config
+, enableCuda ? config.cudaSupport
+, cudaPackages
+, openmp ? null
+}:
+
+stdenv.mkDerivation rec {
+  pname = "suitesparse";
+  version = "5.13.0";
+
+  outputs = [ "out" "dev" "doc" ];
+
+  src = fetchFromGitHub {
+    owner = "DrTimothyAldenDavis";
+    repo = "SuiteSparse";
+    rev = "v${version}";
+    sha256 = "sha256-Anen1YtXsSPhk8DpA4JtADIz9m8oXFl9umlkb4iImf8=";
+  };
+
+  nativeBuildInputs = [
+  ] ++ lib.optionals stdenv.isDarwin [
+    fixDarwinDylibNames
+  ] ++ lib.optionals enableCuda [
+    cudaPackages.cuda_nvcc
+  ];
+
+  # Use compatible indexing for lapack and blas used
+  buildInputs = assert (blas.isILP64 == lapack.isILP64); [
+    blas lapack
+    metis
+    gfortran.cc.lib
+    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
+  ];
+
+  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=${cudaPackages.cuda_nvcc}"
+    "CUDART_LIB=${cudaPackages.cuda_cudart.lib}/lib/libcudart.so"
+    "CUBLAS_LIB=${cudaPackages.libcublas.lib}/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
+    "BLAS=-lblas"
+    "LAPACK=-llapack"
+  ]
+  ;
+
+  env = lib.optionalAttrs stdenv.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";
+  };
+
+  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;
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/math/superlu/add-superlu-lib-as-dependency-for-the-unit-tests.patch b/nixpkgs/pkgs/development/libraries/science/math/superlu/add-superlu-lib-as-dependency-for-the-unit-tests.patch
new file mode 100644
index 000000000000..29d86238af08
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/math/superlu/add-superlu-lib-as-dependency-for-the-unit-tests.patch
@@ -0,0 +1,7 @@
+--- a/TESTING/MATGEN/CMakeLists.txt
++++ b/TESTING/MATGEN/CMakeLists.txt
+@@ -97,3 +97,4 @@ if(enable_complex16)
+ endif()
+ 
+ add_library(matgen ${sources})
++target_link_libraries(matgen superlu)
diff --git a/nixpkgs/pkgs/development/libraries/science/math/superlu/default.nix b/nixpkgs/pkgs/development/libraries/science/math/superlu/default.nix
new file mode 100644
index 000000000000..f99e86ffe478
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/math/superlu/default.nix
@@ -0,0 +1,44 @@
+{ lib, stdenv, fetchurl, cmake,
+  gfortran, blas, lapack}:
+
+assert (!blas.isILP64) && (!lapack.isILP64);
+
+stdenv.mkDerivation rec {
+  version = "5.2.1";
+  pname = "superlu";
+
+  src = fetchurl {
+    url = "http://crd-legacy.lbl.gov/~xiaoye/SuperLU/superlu_${version}.tar.gz";
+    sha256 = "0qzlb7cd608q62kyppd0a8c65l03vrwqql6gsm465rky23b6dyr8";
+  };
+
+  nativeBuildInputs = [ cmake gfortran ];
+
+  propagatedBuildInputs = [ blas ];
+
+  cmakeFlags = [
+    "-DBUILD_SHARED_LIBS=true"
+    "-DUSE_XSDK_DEFAULTS=true"
+  ];
+
+  env = lib.optionalAttrs stdenv.cc.isClang {
+    NIX_CFLAGS_COMPILE = toString [
+      "-Wno-error=implicit-function-declaration"
+      "-Wno-error=implicit-int"
+    ];
+  };
+
+  patches = [
+    ./add-superlu-lib-as-dependency-for-the-unit-tests.patch
+  ];
+
+  doCheck = true;
+  checkTarget = "test";
+
+  meta = {
+    homepage = "http://crd-legacy.lbl.gov/~xiaoye/SuperLU/";
+    license = "http://crd-legacy.lbl.gov/~xiaoye/SuperLU/License.txt";
+    description = "A library for the solution of large, sparse, nonsymmetric systems of linear equations";
+    platforms = lib.platforms.unix;
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/math/sympow/clean-extra-logfile-output-from-pari.patch b/nixpkgs/pkgs/development/libraries/science/math/sympow/clean-extra-logfile-output-from-pari.patch
new file mode 100644
index 000000000000..cbcf18b4cdb2
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/math/sympow/clean-extra-logfile-output-from-pari.patch
@@ -0,0 +1,39 @@
+commit 433a8b99da9d71e96434bd421c2468cbda29d37c
+Author: Mauricio Collares <mauricio@collares.org>
+Date:   Tue Mar 2 22:07:11 2021 -0300
+
+    trim logfile information from pari 2.13 output
+    
+    Pari (since commit 609fb01faf827d91dfa9136849a647a3bbfe8036) prints
+    extra logfile information such as
+    
+      [logfile is "/tmp/nix-shell.2BquN9/home/.sympow/datafiles/P02HM.txt"]
+    
+    which messes up sympow's parsing. This commit reuses the same trimming
+    mechanism already in sympow to trim this new message.
+
+diff --git a/Configure b/Configure
+index 1ef9756..776bec2 100755
+--- a/Configure
++++ b/Configure
+@@ -322,7 +322,7 @@ echo "datafiles/param_data: \$(OTHERb)" >> $FILE
+ echo "	\$(MKDIR) -p datafiles" >> $FILE
+ echo "	\$(TOUCH) datafiles/param_data" >> $FILE
+ echo "	\$(SH) armd.sh" >> $FILE
+-echo "	\$(SED) -i -e '/logfile =/d' datafiles/*.txt" >> $FILE
++echo "	\$(SED) -i -e '/logfile /d' datafiles/*.txt" >> $FILE
+ echo "sympow.1: sympow" >> $FILE
+ echo "	\$(HELP2MAN) \$(H2MFLAGS) -s 1 -n \"SYMPOW program\" -I sympow.h2m -o \$@ ./\$<" >> $FILE
+ echo "clean:" >> $FILE
+diff --git a/generate.c b/generate.c
+index dbb811f..783320c 100644
+--- a/generate.c
++++ b/generate.c
+@@ -148,6 +148,7 @@ static void trimit(char *A)
+    " -e '"
+      "/^\?/d"                           ";"
+      "/^(/d"                            ";"
++	   "/logfile /d"                      ";"
+ 	   "/Warning:/d"                      ";"
+ 	   "/^About to find TOO_BIG/d"        ";"
+ 	   "/^Now working backwards/d"        ";"
diff --git a/nixpkgs/pkgs/development/libraries/science/math/sympow/default.nix b/nixpkgs/pkgs/development/libraries/science/math/sympow/default.nix
new file mode 100644
index 000000000000..09ca356ccdc5
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/math/sympow/default.nix
@@ -0,0 +1,84 @@
+{ lib, stdenv
+, fetchFromGitLab
+, fetchpatch
+, makeWrapper
+, which
+, autoconf
+, help2man
+, file
+, pari
+}:
+
+stdenv.mkDerivation rec {
+  version = "2.023.6";
+  pname = "sympow";
+
+  src = fetchFromGitLab {
+    group = "rezozer";
+    owner = "forks";
+    repo = "sympow";
+    rev = "v${version}";
+    sha256 = "132l0xv00ld1svvv9wh99wfra4zzjv2885h2sq0dsl98wiyvi5zl";
+  };
+
+  patches = [
+    ./clean-extra-logfile-output-from-pari.patch
+    (fetchpatch {
+      name = "null-terminate-dupdirname.patch";
+      url = "https://gitlab.com/rezozer/forks/sympow/-/merge_requests/5.diff";
+      sha256 = "sha256-yKjio+qN9teL8L+mb7WOBN/iv545vRIxW20FJU37oO4=";
+    })
+  ];
+
+  postUnpack = ''
+    patchShebangs .
+  '';
+
+  nativeBuildInputs = [
+    makeWrapper
+    which
+    autoconf
+    help2man
+    file
+    pari
+  ];
+
+  configurePhase = ''
+    runHook preConfigure
+    export PREFIX="$out"
+    export VARPREFIX="$out" # see comment on postInstall
+    ./Configure # doesn't take any options
+    runHook postConfigure
+  '';
+
+  # Usually, sympow has 3 levels of caching: statically distributed in /usr/,
+  # shared in /var and per-user in ~/.sympow. The shared cache assumes trust in
+  # other users and a shared /var is not compatible with nix's approach, so we
+  # set VARPREFIX to the read-only $out. This effectively disables shared
+  # caching. See https://trac.sagemath.org/ticket/3360#comment:36 and sympow's
+  # README for more details on caching.
+  # sympow will complain at runtime about the lack of write-permissions on the
+  # shared cache. We pass the `-quiet` flag by default to disable this.
+  postInstall = ''
+    wrapProgram "$out/bin/sympow" --add-flags '-quiet'
+  '';
+
+  # Example from the README as a sanity check.
+  doInstallCheck = true;
+  installCheckPhase = ''
+    export HOME="$TMP/home"
+    mkdir -p "$HOME"
+    "$out/bin/sympow" -sp 2p16 -curve "[1,2,3,4,5]" | grep '8.3705'
+  '';
+
+  meta = with lib; {
+    description = "Compute special values of symmetric power elliptic curve L-functions";
+    license = {
+      shortName = "sympow";
+      fullName = "Custom, BSD-like. See COPYING file.";
+      free = true;
+    };
+    maintainers = teams.sage.members;
+    platforms = platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/math/tensorflow-lite/default.nix b/nixpkgs/pkgs/development/libraries/science/math/tensorflow-lite/default.nix
new file mode 100644
index 000000000000..1bee7f46d37c
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/math/tensorflow-lite/default.nix
@@ -0,0 +1,108 @@
+{ stdenv
+, bash
+, buildPackages
+, buildBazelPackage
+, fetchFromGitHub
+, lib
+}:
+let
+  buildPlatform = stdenv.buildPlatform;
+  hostPlatform = stdenv.hostPlatform;
+  pythonEnv = buildPackages.python3.withPackages (ps: [ ps.numpy ]);
+  bazelDepsSha256ByBuildAndHost = {
+    x86_64-linux = {
+      x86_64-linux = "sha256-61qmnAB80syYhURWYJOiOnoGOtNa1pPkxfznrFScPAo=";
+      aarch64-linux = "sha256-sOIYpp98wJRz3RGvPasyNEJ05W29913Lsm+oi/aq/Ag=";
+    };
+    aarch64-linux = {
+      aarch64-linux = "sha256-MJU4y9Dt9xJWKgw7iKW+9Ur856rMIHeFD5u05s+Q7rQ=";
+    };
+  };
+  bazelHostConfigName.aarch64-linux = "elinux_aarch64";
+  bazelDepsSha256ByHost =
+    bazelDepsSha256ByBuildAndHost.${buildPlatform.system} or
+      (throw "unsupported build system ${buildPlatform.system}");
+  bazelDepsSha256 = bazelDepsSha256ByHost.${hostPlatform.system} or
+      (throw "unsupported host system ${hostPlatform.system} with build system ${buildPlatform.system}");
+in
+buildBazelPackage rec {
+  name = "tensorflow-lite";
+  version = "2.13.0";
+
+  src = fetchFromGitHub {
+    owner = "tensorflow";
+    repo = "tensorflow";
+    rev = "v${version}";
+    hash = "sha256-Rq5pAVmxlWBVnph20fkAwbfy+iuBNlfFy14poDPd5h0=";
+  };
+
+  bazel = buildPackages.bazel_5;
+
+  nativeBuildInputs = [ pythonEnv buildPackages.perl ];
+
+  bazelTargets = [
+    "//tensorflow/lite:libtensorflowlite.so"
+    "//tensorflow/lite/c:tensorflowlite_c"
+    "//tensorflow/lite/tools/benchmark:benchmark_model"
+    "//tensorflow/lite/tools/benchmark:benchmark_model_performance_options"
+  ];
+
+  bazelFlags = [
+    "--config=opt"
+  ] ++ lib.optionals (hostPlatform.system != buildPlatform.system) [
+    "--config=${bazelHostConfigName.${hostPlatform.system}}"
+  ];
+
+  bazelBuildFlags = [ "--cxxopt=--std=c++17" ];
+
+  buildAttrs = {
+    installPhase = ''
+      mkdir -p $out/{bin,lib}
+
+      # copy the libs and binaries into the output dir
+      cp ./bazel-bin/tensorflow/lite/c/libtensorflowlite_c.so $out/lib
+      cp ./bazel-bin/tensorflow/lite/libtensorflowlite.so $out/lib
+      cp ./bazel-bin/tensorflow/lite/tools/benchmark/benchmark_model $out/bin
+      cp ./bazel-bin/tensorflow/lite/tools/benchmark/benchmark_model_performance_options $out/bin
+
+      find . -type f -name '*.h' | while read f; do
+        path="$out/include/''${f/.\//}"
+        install -D "$f" "$path"
+
+        # remove executable bit from headers
+        chmod -x "$path"
+      done
+    '';
+  };
+
+  fetchAttrs.sha256 = bazelDepsSha256;
+
+  PYTHON_BIN_PATH = pythonEnv.interpreter;
+
+  dontAddBazelOpts = true;
+  removeRulesCC = false;
+
+  postPatch = ''
+    rm .bazelversion
+
+    # Fix gcc-13 build failure by including missing include headers
+    sed -e '1i #include <cstdint>' -i \
+      tensorflow/lite/kernels/internal/spectrogram.cc
+  '';
+
+  preConfigure = ''
+    patchShebangs configure
+  '';
+
+  # configure script freaks out when parameters are passed
+  dontAddPrefix = true;
+  configurePlatforms = [];
+
+  meta = with lib; {
+    description = "An open source deep learning framework for on-device inference.";
+    homepage = "https://www.tensorflow.org/lite";
+    license = licenses.asl20;
+    maintainers = with maintainers; [ mschwaig cpcloud ];
+    platforms = [ "x86_64-linux" "aarch64-linux" ];
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/math/tensorrt/extension.nix b/nixpkgs/pkgs/development/libraries/science/math/tensorrt/extension.nix
new file mode 100644
index 000000000000..ffd9b672684c
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/math/tensorrt/extension.nix
@@ -0,0 +1,156 @@
+final: prev: let
+
+  inherit (final) callPackage;
+  inherit (prev) cudatoolkit cudaVersion lib pkgs;
+
+  ### TensorRT
+
+  buildTensorRTPackage = args:
+    callPackage ./generic.nix { } args;
+
+  toUnderscore = str: lib.replaceStrings ["."] ["_"] str;
+
+  majorMinorPatch = str: lib.concatStringsSep "." (lib.take 3 (lib.splitVersion str));
+
+  tensorRTPackages = with lib; let
+    # Check whether a file is supported for our cuda version
+    isSupported = fileData: elem cudaVersion fileData.supportedCudaVersions;
+    # Return the first file that is supported. In practice there should only ever be one anyway.
+    supportedFile = files: findFirst isSupported null files;
+
+    # Compute versioned attribute name to be used in this package set
+    computeName = version: "tensorrt_${toUnderscore version}";
+
+    # Supported versions with versions as keys and file as value
+    supportedVersions = lib.recursiveUpdate
+      {
+        tensorrt = {
+          enable = false;
+          fileVersionCuda = null;
+          fileVersionCudnn = null;
+          fullVersion = "0.0.0";
+          sha256 = null;
+          tarball = null;
+          supportedCudaVersions = [ ];
+        };
+      }
+      (mapAttrs' (version: attrs: nameValuePair (computeName version) attrs)
+        (filterAttrs (version: file: file != null) (mapAttrs (version: files: supportedFile files) tensorRTVersions)));
+
+    # Add all supported builds as attributes
+    allBuilds = mapAttrs (name: file: buildTensorRTPackage (removeAttrs file ["fileVersionCuda"])) supportedVersions;
+
+    # Set the default attributes, e.g. tensorrt = tensorrt_8_4;
+    defaultName = computeName tensorRTDefaultVersion;
+    defaultBuild = lib.optionalAttrs (allBuilds ? ${defaultName}) { tensorrt = allBuilds.${computeName tensorRTDefaultVersion}; };
+  in {
+    inherit buildTensorRTPackage;
+  } // allBuilds // defaultBuild;
+
+  tarballURL =
+  {fullVersion, fileVersionCuda, fileVersionCudnn ? null} :
+    "TensorRT-${fullVersion}.Linux.x86_64-gnu.cuda-${fileVersionCuda}"
+    + lib.optionalString (fileVersionCudnn != null) ".cudnn${fileVersionCudnn}"
+    + ".tar.gz";
+
+  tensorRTVersions = {
+    "8.6.1" = [
+      rec {
+        fileVersionCuda = "12.0";
+        fullVersion = "8.6.1.6";
+        sha256 = "sha256-D4FXpfxTKZQ7M4uJNZE3M1CvqQyoEjnNrddYDNHrolQ=";
+        tarball = tarballURL { inherit fileVersionCuda fullVersion; };
+        supportedCudaVersions = [ "12.0" "12.1" ];
+      }
+    ];
+    "8.5.3" = [
+      rec {
+        fileVersionCuda = "11.8";
+        fileVersionCudnn = "8.6";
+        fullVersion = "8.5.3.1";
+        sha256 = "sha256-BNeuOYvPTUAfGxI0DVsNrX6Z/FAB28+SE0ptuGu7YDY=";
+        tarball = tarballURL { inherit fileVersionCuda fileVersionCudnn fullVersion; };
+        supportedCudaVersions = [ "11.0" "11.1" "11.2" "11.3" "11.4" "11.5" "11.6" "11.7" "11.8" ];
+      }
+      rec {
+        fileVersionCuda = "10.2";
+        fileVersionCudnn = "8.6";
+        fullVersion = "8.5.3.1";
+        sha256 = "sha256-WCt6yfOmFbrjqdYCj6AE2+s2uFpISwk6urP+2I0BnGQ=";
+        tarball = tarballURL { inherit fileVersionCuda fileVersionCudnn fullVersion; };
+        supportedCudaVersions = [ "10.2" ];
+      }
+    ];
+    "8.5.2" = [
+      rec {
+        fileVersionCuda = "11.8";
+        fileVersionCudnn = "8.6";
+        fullVersion = "8.5.2.2";
+        sha256 = "sha256-Ov5irNS/JETpEz01FIFNMs9YVmjGHL7lSXmDpgCdgao=";
+        tarball = tarballURL { inherit fileVersionCuda fileVersionCudnn fullVersion; };
+        supportedCudaVersions = [ "11.0" "11.1" "11.2" "11.3" "11.4" "11.5" "11.6" "11.7" "11.8" ];
+      }
+      rec {
+        fileVersionCuda = "10.2";
+        fileVersionCudnn = "8.6";
+        fullVersion = "8.5.2.2";
+        sha256 = "sha256-UruwQShYcHLY5d81lKNG7XaoUsZr245c+PUpUN6pC5E=";
+        tarball = tarballURL { inherit fileVersionCuda fileVersionCudnn fullVersion; };
+        supportedCudaVersions = [ "10.2" ];
+      }
+    ];
+    "8.5.1" = [
+      rec {
+        fileVersionCuda = "11.8";
+        fileVersionCudnn = "8.6";
+        fullVersion = "8.5.1.7";
+        sha256 = "sha256-Ocx/B3BX0TY3lOj/UcTPIaXb7M8RFrACC6Da4PMGMHY=";
+        tarball = tarballURL { inherit fileVersionCuda fileVersionCudnn fullVersion; };
+        supportedCudaVersions = [ "11.0" "11.1" "11.2" "11.3" "11.4" "11.5" "11.6" "11.7" "11.8" ];
+      }
+      rec {
+        fileVersionCuda = "10.2";
+        fileVersionCudnn = "8.6";
+        fullVersion = "8.5.1.7";
+        sha256 = "sha256-CcFGJhw7nFdPnSYYSxcto2MHK3F84nLQlJYjdIw8dPM=";
+        tarball = tarballURL { inherit fileVersionCuda fileVersionCudnn fullVersion; };
+        supportedCudaVersions = [ "10.2" ];
+      }
+    ];
+    "8.4.0" = [
+      rec {
+        fileVersionCuda = "11.6";
+        fileVersionCudnn = "8.3";
+        fullVersion = "8.4.0.6";
+        sha256 = "sha256-DNgHHXF/G4cK2nnOWImrPXAkOcNW6Wy+8j0LRpAH/LQ=";
+        tarball = tarballURL { inherit fileVersionCuda fileVersionCudnn fullVersion; };
+        supportedCudaVersions = [ "11.0" "11.1" "11.2" "11.3" "11.4" "11.5" "11.6" ];
+      }
+      rec {
+        fileVersionCuda = "10.2";
+        fileVersionCudnn = "8.3";
+        fullVersion = "8.4.0.6";
+        sha256 = "sha256-aCzH0ZI6BrJ0v+e5Bnm7b8mNltA7NNuIa8qRKzAQv+I=";
+        tarball = tarballURL { inherit fileVersionCuda fileVersionCudnn fullVersion; };
+        supportedCudaVersions = [ "10.2" ];
+      }
+    ];
+  };
+
+  # Default attributes
+  tensorRTDefaultVersion = {
+    "10.2" = "8.4.0";
+    "11.0" = "8.4.0";
+    "11.1" = "8.4.0";
+    "11.2" = "8.4.0";
+    "11.3" = "8.4.0";
+    "11.4" = "8.4.0";
+    "11.5" = "8.4.0";
+    "11.6" = "8.4.0";
+    "11.7" = "8.5.3";
+    "11.8" = "8.5.3";
+    "12.0" = "8.6.1";
+    "12.1" = "8.6.1";
+  }.${cudaVersion} or "8.4.0";
+
+in tensorRTPackages
diff --git a/nixpkgs/pkgs/development/libraries/science/math/tiny-cuda-nn/default.nix b/nixpkgs/pkgs/development/libraries/science/math/tiny-cuda-nn/default.nix
new file mode 100644
index 000000000000..2036c4c86253
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/math/tiny-cuda-nn/default.nix
@@ -0,0 +1,163 @@
+{
+  cmake,
+  cudaPackages,
+  fetchFromGitHub,
+  lib,
+  ninja,
+  python3Packages ? {},
+  pythonSupport ? false,
+  stdenv,
+  symlinkJoin,
+  which,
+}: let
+  inherit (lib) lists strings;
+  inherit (cudaPackages) backendStdenv cudaFlags;
+
+  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
+  ];
+
+  cuda-native-redist = symlinkJoin {
+    name = "cuda-redist";
+    paths = with cudaPackages;
+      [cuda_nvcc]
+      ++ cuda-common-redist;
+  };
+
+  cuda-redist = symlinkJoin {
+    name = "cuda-redist";
+    paths = cuda-common-redist;
+  };
+in
+  stdenv.mkDerivation (finalAttrs: {
+    pname = "tiny-cuda-nn";
+    version = "1.6";
+    strictDeps = true;
+
+    format = strings.optionalString pythonSupport "setuptools";
+
+    src = fetchFromGitHub {
+      owner = "NVlabs";
+      repo = finalAttrs.pname;
+      rev = "v${finalAttrs.version}";
+      fetchSubmodules = true;
+      hash = "sha256-qW6Fk2GB71fvZSsfu+mykabSxEKvaikZ/pQQZUycOy0=";
+    };
+
+    nativeBuildInputs =
+      [
+        cmake
+        cuda-native-redist
+        ninja
+        which
+      ]
+      ++ lists.optionals pythonSupport (with python3Packages; [
+        pip
+        setuptools
+        wheel
+      ]);
+
+    buildInputs =
+      [
+        cuda-redist
+      ]
+      ++ lib.optionals pythonSupport (
+        with python3Packages; [
+          pybind11
+          python
+        ]
+      );
+
+    propagatedBuildInputs = lib.optionals pythonSupport (
+      with python3Packages; [
+        torch
+      ]
+    );
+
+    # NOTE: We cannot use pythonImportsCheck for this module because it uses torch to immediately
+    #   initailize CUDA and GPU access is not allowed in the nix build environment.
+    # NOTE: There are no tests for the C++ library or the python bindings, so we just skip the check
+    #   phase -- we're not missing anything.
+    doCheck = false;
+
+    preConfigure = ''
+      export TCNN_CUDA_ARCHITECTURES="${
+        strings.concatStringsSep ";" (lists.map cudaFlags.dropDot cudaFlags.cudaCapabilities)
+      }"
+      export CUDA_HOME="${cuda-native-redist}"
+      export LIBRARY_PATH="${cuda-native-redist}/lib/stubs:$LIBRARY_PATH"
+      export CC="${backendStdenv.cc}/bin/cc"
+      export CXX="${backendStdenv.cc}/bin/c++"
+    '';
+
+    # When building the python bindings, we cannot re-use the artifacts from the C++ build so we
+    # skip the CMake confurePhase and the buildPhase.
+    dontUseCmakeConfigure = pythonSupport;
+
+    # The configurePhase usually puts you in the build directory, so for the python bindings we
+    # need to change directories to the source directory.
+    configurePhase = strings.optionalString pythonSupport ''
+      runHook preConfigure
+      mkdir -p "$NIX_BUILD_TOP/build"
+      cd "$NIX_BUILD_TOP/build"
+      runHook postConfigure
+    '';
+
+    buildPhase = strings.optionalString pythonSupport ''
+      runHook preBuild
+      python -m pip wheel \
+        --no-build-isolation \
+        --no-clean \
+        --no-deps \
+        --no-index \
+        --verbose \
+        --wheel-dir "$NIX_BUILD_TOP/build" \
+        "$NIX_BUILD_TOP/source/bindings/torch"
+      runHook postBuild
+    '';
+
+    installPhase =
+      ''
+        runHook preInstall
+        mkdir -p "$out/lib"
+      ''
+      # Installing the C++ library just requires copying the static library to the output directory
+      + strings.optionalString (!pythonSupport) ''
+        cp libtiny-cuda-nn.a "$out/lib/"
+      ''
+      # Installing the python bindings requires building the wheel and installing it
+      + strings.optionalString pythonSupport ''
+        python -m pip install \
+          --no-build-isolation \
+          --no-cache-dir \
+          --no-deps \
+          --no-index \
+          --no-warn-script-location \
+          --prefix="$out" \
+          --verbose \
+          ./*.whl
+      ''
+      + ''
+        runHook postInstall
+      '';
+
+    passthru = {
+      inherit cudaPackages;
+    };
+
+    meta = with lib; {
+      description = "Lightning fast C++/CUDA neural network framework";
+      homepage = "https://github.com/NVlabs/tiny-cuda-nn";
+      license = licenses.bsd3;
+      maintainers = with maintainers; [connorbaker];
+      platforms = platforms.linux;
+    };
+  })
diff --git a/nixpkgs/pkgs/development/libraries/science/math/trilinos/default.nix b/nixpkgs/pkgs/development/libraries/science/math/trilinos/default.nix
new file mode 100644
index 000000000000..1939b0a5307b
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/math/trilinos/default.nix
@@ -0,0 +1,102 @@
+{ stdenv
+, lib
+, fetchFromGitHub
+, blas
+, boost
+, cmake
+, gfortran
+, lapack
+, mpi
+, suitesparse
+, swig
+, withMPI ? false
+}:
+
+# NOTE: Not all packages are enabled.  We specifically enable the ones
+# required to build Xyce. If the need comes, we can enable more of them.
+
+let
+  flagsBase = ''
+    -G "Unix Makefiles"
+    -DBUILD_SHARED_LIBS=ON
+    -DCMAKE_CXX_FLAGS="-O3 -fPIC"
+    -DCMAKE_C_FLAGS="-O3 -fPIC"
+    -DCMAKE_Fortran_FLAGS="-O3 -fPIC"
+    -DTrilinos_ENABLE_NOX=ON
+    -DNOX_ENABLE_LOCA=ON
+    -DTrilinos_ENABLE_EpetraExt=ON
+    -DEpetraExt_BUILD_BTF=ON
+    -DEpetraExt_BUILD_EXPERIMENTAL=ON
+    -DEpetraExt_BUILD_GRAPH_REORDERINGS=ON
+    -DTrilinos_ENABLE_TrilinosCouplings=ON
+    -DTrilinos_ENABLE_Ifpack=ON
+    -DTrilinos_ENABLE_AztecOO=ON
+    -DTrilinos_ENABLE_Belos=ON
+    -DTrilinos_ENABLE_Teuchos=ON
+    -DTeuchos_ENABLE_COMPLEX=ON
+    -DTrilinos_ENABLE_Amesos=ON
+    -DAmesos_ENABLE_KLU=ON
+    -DTrilinos_ENABLE_Amesos2=ON
+    -DAmesos2_ENABLE_KLU2=ON
+    -DAmesos2_ENABLE_Basker=ON
+    -DTrilinos_ENABLE_Sacado=ON
+    -DTrilinos_ENABLE_Stokhos=ON
+    -DTrilinos_ENABLE_Kokkos=ON
+    -DTrilinos_ENABLE_ALL_OPTIONAL_PACKAGES=OFF
+    -DTrilinos_ENABLE_CXX11=ON
+    -DTPL_ENABLE_AMD=ON
+    -DTPL_ENABLE_BLAS=ON
+    -DTPL_ENABLE_LAPACK=ON
+  '';
+  flagsParallel = ''
+    -DCMAKE_C_COMPILER=mpicc
+    -DCMAKE_CXX_COMPILER=mpic++
+    -DCMAKE_Fortran_COMPILER=mpif77
+    -DTrilinos_ENABLE_Isorropia=ON
+    -DTrilinos_ENABLE_Zoltan=ON
+    -DTPL_ENABLE_MPI=ON
+  '';
+in
+stdenv.mkDerivation rec {
+  pname = "trilinos";
+  # Xyce 7.4 requires version 12.12.1
+  # nixpkgs-update: no auto update
+  version = "12.12.1";
+
+  src = fetchFromGitHub {
+    owner = "trilinos";
+    repo = "Trilinos";
+    rev = "${pname}-release-${lib.replaceStrings [ "." ] [ "-" ] version}";
+    sha256 = "sha256-Nqjr7RAlUHm6vs87a1P84Y7BIZEL0Vs/A1Z6dykfv+o=";
+  };
+
+  nativeBuildInputs = [ cmake gfortran swig ];
+
+  buildInputs = [ blas boost lapack suitesparse ] ++ lib.optionals withMPI [ mpi ];
+
+  preConfigure =
+    if withMPI then ''
+      cmakeFlagsArray+=(${flagsBase} ${flagsParallel})
+    ''
+    else ''
+      cmakeFlagsArray+=(${flagsBase})
+    '';
+
+  passthru = {
+    inherit withMPI;
+  };
+
+  meta = with lib; {
+    description = "Engineering and scientific problems algorithms";
+    longDescription = ''
+      The Trilinos Project is an effort to develop algorithms and enabling
+      technologies within an object-oriented software framework for the
+      solution of large-scale, complex multi-physics engineering and scientific
+      problems.
+    '';
+    homepage = "https://trilinos.org";
+    license = licenses.bsd3;
+    maintainers = with maintainers; [ fbeffa ];
+    platforms = platforms.all;
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/math/wcpg/default.nix b/nixpkgs/pkgs/development/libraries/science/math/wcpg/default.nix
new file mode 100644
index 000000000000..8f14b940f383
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/math/wcpg/default.nix
@@ -0,0 +1,44 @@
+{ lib
+, stdenv
+, fetchFromGitHub
+, autoreconfHook
+, blas
+, gmp
+, lapack
+, libf2c
+, mpfi
+, mpfr
+}:
+
+stdenv.mkDerivation rec {
+  pname = "wcpg";
+  version = "0.9";
+
+  src = fetchFromGitHub {
+    owner = "fixif";
+    repo = pname;
+    rev = version;
+    sha256 = "sha256-uA/ENjf4urEO+lqebkp/k54199o2434FYgPSmYCG4UA=";
+  };
+
+  nativeBuildInputs = [
+    autoreconfHook
+  ];
+
+  buildInputs = [
+    blas
+    gmp
+    lapack
+    libf2c
+    mpfi
+    mpfr
+  ];
+
+  meta = with lib; {
+    description = "Worst-Case Peak-Gain library";
+    homepage = "https://github.com/fixif/WCPG";
+    license = licenses.cecill-b;
+    platforms = platforms.unix;
+    maintainers = with maintainers; [ wegank ];
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/math/zn_poly/default.nix b/nixpkgs/pkgs/development/libraries/science/math/zn_poly/default.nix
new file mode 100644
index 000000000000..bdaf6e6284ef
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/math/zn_poly/default.nix
@@ -0,0 +1,64 @@
+{ stdenv
+, lib
+, fetchFromGitLab
+, fetchpatch
+, gmp
+, python3
+, tune ? false # tune to hardware, impure
+}:
+
+stdenv.mkDerivation rec {
+  version = "0.9.2";
+  pname = "zn_poly";
+
+  # sage has picked up the maintenance (bug fixes and building, not development)
+  # from the original, now unmaintained project which can be found at
+  # http://web.maths.unsw.edu.au/~davidharvey/code/zn_poly/
+  src = fetchFromGitLab {
+    owner = "sagemath";
+    repo = "zn_poly";
+    rev = version;
+    hash = "sha256-QBItcrrpOGj22/ShTDdfZjm63bGW2xY4c71R1q8abPE=";
+  };
+
+  buildInputs = [
+    gmp
+  ];
+
+  nativeBuildInputs = [
+    python3 # needed by ./configure to create the makefile
+  ];
+
+  # name of library file ("libzn_poly.so")
+  libbasename = "libzn_poly";
+  libext = stdenv.hostPlatform.extensions.sharedLibrary;
+
+  makeFlags = [ "CC=${stdenv.cc.targetPrefix}cc" ];
+
+  # Tuning (either autotuning or with hand-written parameters) is possible
+  # but not implemented here.
+  # It seems buggy anyways (see homepage).
+  buildFlags = [ "all" "${libbasename}${libext}" ];
+
+  configureFlags = lib.optionals (!tune) [
+    "--disable-tuning"
+  ];
+
+  # `make install` fails to install some header files and the lib file.
+  installPhase = ''
+    mkdir -p "$out/include/zn_poly"
+    mkdir -p "$out/lib"
+    cp "${libbasename}"*"${libext}" "$out/lib"
+    cp include/*.h "$out/include/zn_poly"
+  '';
+
+  doCheck = true;
+
+  meta = with lib; {
+    homepage = "https://web.maths.unsw.edu.au/~davidharvey/code/zn_poly/";
+    description = "Polynomial arithmetic over Z/nZ";
+    license = with licenses; [ gpl3 ];
+    maintainers = teams.sage.members;
+    platforms = platforms.unix;
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/networking/ns-3/default.nix b/nixpkgs/pkgs/development/libraries/science/networking/ns-3/default.nix
new file mode 100644
index 000000000000..fa6e5e48f846
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/networking/ns-3/default.nix
@@ -0,0 +1,143 @@
+{ stdenv
+, breakpointHook
+, fetchFromGitLab
+, python
+, libxml2
+, sqlite
+
+, boost
+, gtk3-x11
+, root
+, glib
+, gsl
+
+, cmake
+, pkg-config
+
+
+, libpcap
+
+, jansson
+
+, harfbuzz
+, freetype
+
+  # for binding generation
+, castxml ? null
+, cppyy ? null
+
+  # can take a long time, generates > 30000 images/graphs
+, enableDoxygen ? false
+
+  # very long
+, withManual ? false
+, doxygen ? null
+, graphviz ? null
+, imagemagick ? null
+  # for manual, tetex is used to get the eps2pdf binary
+  # texlive to get latexmk. building manual still fails though
+, dia
+, tetex ? null
+, ghostscript ? null
+, texliveMedium ? null
+
+  # generates python bindings
+, pythonSupport ? true
+, ncurses ? null
+
+, lib
+}:
+
+let
+  pythonEnv = python.withPackages (ps:
+    lib.optional withManual ps.sphinx
+    ++ lib.optionals pythonSupport (with ps;[ pybindgen pygccxml cppyy])
+  );
+in
+stdenv.mkDerivation rec {
+  pname = "ns-3";
+  version = "39";
+
+  src = fetchFromGitLab {
+    owner = "nsnam";
+    repo = "ns-3-dev";
+    rev = "ns-3.${version}";
+    sha256 = "sha256-2d8xCCfxRpcCZgt7ne17F7cUo/wIxLyvjQs3izNUnmY=";
+  };
+
+  nativeBuildInputs = [ cmake pkg-config pythonEnv ];
+
+  outputs = [ "out" ];
+
+  # ncurses is a hidden dependency of waf when checking python
+  buildInputs = lib.optionals pythonSupport [ castxml ncurses ]
+    ++ lib.optionals enableDoxygen [ doxygen graphviz imagemagick ]
+    ++ lib.optionals withManual [ dia tetex ghostscript imagemagick texliveMedium ]
+    ++ [
+    libxml2
+    pythonEnv
+    sqlite.dev
+    gsl
+    boost
+    root
+    glib.out
+    glib.dev
+    libpcap
+    gtk3-x11.dev
+    harfbuzz
+    freetype
+    jansson
+  ];
+
+  propagatedBuildInputs = [ pythonEnv ];
+
+  preConfigure = ''
+     substituteInPlace src/tap-bridge/CMakeLists.txt \
+       --replace '-DTAP_CREATOR="''${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/src/tap-bridge/' "-DTAP_CREATOR=\"$out/libexec/ns3/"
+
+    substituteInPlace src/fd-net-device/CMakeLists.txt \
+      --replace '-DRAW_SOCK_CREATOR="''${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/src/fd-net-device/' "-DRAW_SOCK_CREATOR=\"$out/libexec/ns3/"
+
+    substituteInPlace src/fd-net-device/CMakeLists.txt \
+      --replace '-DTAP_DEV_CREATOR="''${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/src/fd-net-device/' "-DTAP_DEV_CREATOR=\"$out/libexec/ns3/"
+  '';
+
+  doCheck = false;
+
+  buildTargets = "build"
+    + lib.optionalString enableDoxygen " doxygen"
+    + lib.optionalString withManual "sphinx";
+
+  # to prevent fatal error: 'backward_warning.h' file not found
+  CXXFLAGS = "-D_GLIBCXX_PERMIT_BACKWARD_HASH";
+
+  # Make generated python bindings discoverable in customized python environment
+  passthru = { pythonModule = python; };
+
+  cmakeFlags = [
+    "-DPython3_LIBRARY_DIRS=${pythonEnv}/lib"
+    "-DPython3_INCLUDE_DIRS=${pythonEnv}/include"
+    "-DPython3_EXECUTABLE=${pythonEnv}/bin/python"
+    "-DNS3_PYTHON_BINDINGS=ON"
+    "-DNS3_DES_METRICS=ON"
+    "-DNS3_BINDINGS_INSTALL_DIR=${pythonEnv.sitePackages}"
+    "-DNS3_LOG=ON"
+    "-DNS3_ASSERT=ON"
+    "-DNS3_GTK3=ON"
+    "-DGTK3_GLIBCONFIG_INCLUDE_DIR=${glib.out}/lib/glib-2.0/include"
+  ]
+    ++ lib.optional doCheck "-DNS3_TESTS=ON";
+
+  # strictoverflow prevents clang from discovering pyembed when bindings
+  hardeningDisable = [ "fortify" "strictoverflow" ];
+
+  meta = with lib; {
+    homepage = "http://www.nsnam.org";
+    license = licenses.gpl3;
+    description = "A discrete time event network simulator";
+    platforms = with platforms; unix;
+    maintainers = with maintainers; [ teto rgrunbla ];
+    # never built on aarch64-darwin since first introduction in nixpkgs
+    broken = (stdenv.isDarwin && stdenv.isAarch64) || (stdenv.isLinux && stdenv.isAarch64);
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/robotics/edgetpu-compiler/default.nix b/nixpkgs/pkgs/development/libraries/science/robotics/edgetpu-compiler/default.nix
new file mode 100644
index 000000000000..5e02398d1b4e
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/robotics/edgetpu-compiler/default.nix
@@ -0,0 +1,59 @@
+{ autoPatchelfHook
+, dpkg
+, fetchurl
+, lib
+, libcxx
+, stdenv
+}:
+stdenv.mkDerivation rec {
+  pname = "edgetpu-compiler";
+  version = "15.0";
+
+  src = fetchurl rec {
+    url = "https://packages.cloud.google.com/apt/pool/${pname}_${version}_amd64_${sha256}.deb";
+    sha256 = "ce03822053c2bddbb8640eaa988396ae66f9bc6b9d6d671914acd1727c2b445a";
+  };
+
+  nativeBuildInputs = [
+    autoPatchelfHook
+    dpkg
+  ];
+
+  buildInputs = [
+    libcxx
+  ];
+
+  unpackPhase = ''
+    mkdir bin pkg
+
+    dpkg -x $src pkg
+
+    rm -r pkg/usr/share/lintian
+
+    cp pkg/usr/bin/edgetpu_compiler_bin/edgetpu_compiler ./bin
+    cp -r pkg/usr/share .
+
+    rm -r pkg
+  '';
+
+  dontConfigure = true;
+  dontBuild = true;
+
+  installPhase = ''
+    runHook preInstall
+
+    mkdir -p $out
+    cp -r ./{bin,share} $out
+
+    runHook postInstall
+  '';
+
+  meta = with lib; {
+    description = "A command line tool that compiles a TensorFlow Lite model into an Edge TPU compatible file.";
+    homepage = "https://coral.ai/docs/edgetpu/compiler";
+    sourceProvenance = with sourceTypes; [ binaryNativeCode ];
+    license = licenses.asl20;
+    maintainers = with maintainers; [ cpcloud ];
+    platforms = [ "x86_64-linux" ];
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/robotics/ispike/default.nix b/nixpkgs/pkgs/development/libraries/science/robotics/ispike/default.nix
new file mode 100644
index 000000000000..28a38b7056dd
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/robotics/ispike/default.nix
@@ -0,0 +1,26 @@
+{ lib, stdenv, fetchurl, cmake, boost }:
+
+stdenv.mkDerivation rec {
+  pname = "ispike";
+  version = "2.1.1";
+
+  src = fetchurl {
+    url = "mirror://sourceforge/ispike/${pname}-${version}.tar.gz";
+    sha256 = "0khrxp43bi5kisr8j4lp9fl4r5marzf7b4inys62ac108sfb28lp";
+  };
+
+  postPatch = ''
+    sed -i "1i #include <map>" include/iSpike/YarpConnection.hpp
+  '';
+
+  nativeBuildInputs = [ cmake ];
+  buildInputs = [ boost ];
+
+  meta = {
+    description = "Spiking neural interface between iCub and a spiking neural simulator";
+    homepage = "https://sourceforge.net/projects/ispike/";
+    license = lib.licenses.lgpl3;
+    platforms = lib.platforms.unix;
+    maintainers = [ lib.maintainers.nico202 ];
+  };
+}