about summary refs log tree commit diff
path: root/pkgs/applications/science/math
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/applications/science/math')
-rw-r--r--pkgs/applications/science/math/4ti2/default.nix38
-rw-r--r--pkgs/applications/science/math/R/default.nix6
-rw-r--r--pkgs/applications/science/math/bcal/default.nix2
-rw-r--r--pkgs/applications/science/math/caffe/default.nix6
-rw-r--r--pkgs/applications/science/math/cbc/default.nix2
-rw-r--r--pkgs/applications/science/math/cemu-ti/default.nix28
-rw-r--r--pkgs/applications/science/math/colpack/default.nix2
-rw-r--r--pkgs/applications/science/math/cplex/default.nix7
-rw-r--r--pkgs/applications/science/math/dap/default.nix37
-rw-r--r--pkgs/applications/science/math/ecm/default.nix2
-rw-r--r--pkgs/applications/science/math/eigenmath/default.nix6
-rw-r--r--pkgs/applications/science/math/fricas/default.nix4
-rw-r--r--pkgs/applications/science/math/gap/default.nix8
-rw-r--r--pkgs/applications/science/math/geogebra/default.nix2
-rw-r--r--pkgs/applications/science/math/geogebra/geogebra6.nix27
-rw-r--r--pkgs/applications/science/math/getdp/default.nix7
-rw-r--r--pkgs/applications/science/math/gfan/default.nix8
-rw-r--r--pkgs/applications/science/math/giac/default.nix39
-rw-r--r--pkgs/applications/science/math/giac/fix-fltk-guard.patch28
-rw-r--r--pkgs/applications/science/math/giac/increase-pari-stack-size.patch18
-rw-r--r--pkgs/applications/science/math/giac/remove-old-functional-patterns.patch294
-rw-r--r--pkgs/applications/science/math/ginac/default.nix2
-rw-r--r--pkgs/applications/science/math/glsurf/default.nix4
-rw-r--r--pkgs/applications/science/math/gmsh/default.nix2
-rw-r--r--pkgs/applications/science/math/gurobi/default.nix4
-rw-r--r--pkgs/applications/science/math/lp_solve/default.nix8
-rw-r--r--pkgs/applications/science/math/mathematica/10.nix132
-rw-r--r--pkgs/applications/science/math/mathematica/11.nix146
-rw-r--r--pkgs/applications/science/math/mathematica/9.nix118
-rw-r--r--pkgs/applications/science/math/mathematica/default.nix14
-rw-r--r--pkgs/applications/science/math/mathematica/generic.nix28
-rw-r--r--pkgs/applications/science/math/mathematica/versions.nix42
-rw-r--r--pkgs/applications/science/math/maxima/5.47.0-CVE-2024-34490.patch86
-rw-r--r--pkgs/applications/science/math/maxima/default.nix8
-rw-r--r--pkgs/applications/science/math/msieve/default.nix6
-rw-r--r--pkgs/applications/science/math/mxnet/default.nix2
-rw-r--r--pkgs/applications/science/math/nota/default.nix2
-rw-r--r--pkgs/applications/science/math/numworks-epsilon/default.nix4
-rw-r--r--pkgs/applications/science/math/palp/default.nix2
-rw-r--r--pkgs/applications/science/math/qalculate-gtk/default.nix6
-rw-r--r--pkgs/applications/science/math/qalculate-qt/default.nix8
-rw-r--r--pkgs/applications/science/math/ratpoints/default.nix2
-rw-r--r--pkgs/applications/science/math/ripser/default.nix19
-rw-r--r--pkgs/applications/science/math/sage/README.md2
-rw-r--r--pkgs/applications/science/math/sage/default.nix3
-rw-r--r--pkgs/applications/science/math/sage/dist-tests.nix8
-rw-r--r--pkgs/applications/science/math/sage/patches/disable-singular-doctest.patch36
-rw-r--r--pkgs/applications/science/math/sage/patches/gap-element-crash.patch18
-rw-r--r--pkgs/applications/science/math/sage/patches/silence-linker.patch27
-rw-r--r--pkgs/applications/science/math/sage/patches/sphinx-docbuild-subprocesses.patch10
-rw-r--r--pkgs/applications/science/math/sage/python-modules/sage-docbuild.nix2
-rw-r--r--pkgs/applications/science/math/sage/sage-env.nix6
-rw-r--r--pkgs/applications/science/math/sage/sage-src.nix49
-rw-r--r--pkgs/applications/science/math/sage/sage-tests.nix2
-rw-r--r--pkgs/applications/science/math/sage/sage.nix2
-rw-r--r--pkgs/applications/science/math/sage/sagelib.nix9
-rw-r--r--pkgs/applications/science/math/scalp/default.nix4
-rw-r--r--pkgs/applications/science/math/scilab-bin/default.nix2
-rw-r--r--pkgs/applications/science/math/singular/default.nix24
-rw-r--r--pkgs/applications/science/math/speedcrunch/default.nix2
-rw-r--r--pkgs/applications/science/math/symmetrica/default.nix4
-rw-r--r--pkgs/applications/science/math/wolfram-engine/default.nix10
-rw-r--r--pkgs/applications/science/math/wolfram-engine/l10ns.nix17
-rw-r--r--pkgs/applications/science/math/wolfram-engine/notebook.nix2
-rw-r--r--pkgs/applications/science/math/wxmaxima/default.nix4
-rw-r--r--pkgs/applications/science/math/yacas/default.nix2
66 files changed, 752 insertions, 709 deletions
diff --git a/pkgs/applications/science/math/4ti2/default.nix b/pkgs/applications/science/math/4ti2/default.nix
deleted file mode 100644
index 940e2e45d5acf..0000000000000
--- a/pkgs/applications/science/math/4ti2/default.nix
+++ /dev/null
@@ -1,38 +0,0 @@
-{ lib
-, stdenv
-, fetchFromGitHub
-, autoreconfHook
-, glpk
-, gmp
-}:
-
-stdenv.mkDerivation rec{
-  pname = "4ti2";
-  version = "1.6.10";
-
-  src = fetchFromGitHub {
-    owner = pname;
-    repo = pname;
-    rev = "Release_${builtins.replaceStrings ["."] ["_"] version}";
-    hash = "sha256-Rz8O1Tf81kzpTGPq7dkZJvv444F1/VqKu7VuRvH59kQ=";
-  };
-
-  nativeBuildInputs = [
-    autoreconfHook
-  ];
-
-  buildInputs = [
-    glpk
-    gmp
-  ];
-
-  installFlags = [ "install-exec" ];
-
-  meta = with lib;{
-    homepage = "https://4ti2.github.io/";
-    description = "Software package for algebraic, geometric and combinatorial problems on linear spaces";
-    license = with licenses; [ gpl2Plus ];
-    maintainers = with maintainers; [ AndersonTorres ];
-    platforms = platforms.all;
-  };
-}
diff --git a/pkgs/applications/science/math/R/default.nix b/pkgs/applications/science/math/R/default.nix
index b6fac3cca9e5a..f2825e13568a8 100644
--- a/pkgs/applications/science/math/R/default.nix
+++ b/pkgs/applications/science/math/R/default.nix
@@ -33,7 +33,7 @@ stdenv.mkDerivation (finalAttrs: {
     bzip2 gfortran libX11 libXmu libXt libXt libjpeg libpng libtiff ncurses
     pango pcre2 perl readline (texliveSmall.withPackages (ps: with ps; [ inconsolata helvetic ps.texinfo fancyvrb cm-super rsfs ])) xz zlib less texinfo graphviz icu
     bison imake which blas lapack curl tcl tk jdk tzdata
-  ] ++ lib.optionals stdenv.isDarwin [ Cocoa Foundation libobjc libcxx ];
+  ] ++ lib.optionals stdenv.hostPlatform.isDarwin [ Cocoa Foundation libobjc libcxx ];
 
   patches = [
     ./no-usr-local-search-paths.patch
@@ -41,7 +41,7 @@ stdenv.mkDerivation (finalAttrs: {
 
   # Test of the examples for package 'tcltk' fails in Darwin sandbox. See:
   # https://github.com/NixOS/nixpkgs/issues/146131
-  postPatch = lib.optionalString stdenv.isDarwin ''
+  postPatch = lib.optionalString stdenv.hostPlatform.isDarwin ''
     substituteInPlace configure \
       --replace "-install_name libRblas.dylib" "-install_name $out/lib/R/lib/libRblas.dylib" \
       --replace "-install_name libRlapack.dylib" "-install_name $out/lib/R/lib/libRlapack.dylib" \
@@ -77,7 +77,7 @@ stdenv.mkDerivation (finalAttrs: {
       RANLIB=$(type -p ranlib)
       r_cv_have_curl728=yes
       R_SHELL="${stdenv.shell}"
-  '' + lib.optionalString stdenv.isDarwin ''
+  '' + lib.optionalString stdenv.hostPlatform.isDarwin ''
       --disable-R-framework
       --without-x
       OBJC="clang"
diff --git a/pkgs/applications/science/math/bcal/default.nix b/pkgs/applications/science/math/bcal/default.nix
index 9ba028d1cb650..6e87136170c64 100644
--- a/pkgs/applications/science/math/bcal/default.nix
+++ b/pkgs/applications/science/math/bcal/default.nix
@@ -33,6 +33,6 @@ stdenv.mkDerivation rec {
     homepage = "https://github.com/jarun/bcal";
     license = licenses.gpl3Only;
     platforms = platforms.unix;
-    maintainers = with maintainers; [ ];
+    maintainers = [ ];
   };
 }
diff --git a/pkgs/applications/science/math/caffe/default.nix b/pkgs/applications/science/math/caffe/default.nix
index 2a84d4b27b141..f82cef9d881cb 100644
--- a/pkgs/applications/science/math/caffe/default.nix
+++ b/pkgs/applications/science/math/caffe/default.nix
@@ -73,14 +73,14 @@ stdenv.mkDerivation rec {
                 ++ lib.optional ncclSupport nccl
                 ++ lib.optionals leveldbSupport [ leveldb snappy ]
                 ++ lib.optionals pythonSupport [ python numpy ]
-                ++ lib.optionals stdenv.isDarwin [ Accelerate CoreGraphics CoreVideo ]
+                ++ lib.optionals stdenv.hostPlatform.isDarwin [ Accelerate CoreGraphics CoreVideo ]
                 ;
 
   propagatedBuildInputs = lib.optionals pythonSupport (
     # requirements.txt
     let pp = python.pkgs; in ([
       pp.numpy pp.scipy pp.scikit-image pp.h5py
-      pp.matplotlib pp.ipython pp.networkx pp.nose
+      pp.matplotlib pp.ipython pp.networkx
       pp.pandas pp.python-dateutil pp.protobuf pp.gflags
       pp.pyyaml pp.pillow pp.six
     ] ++ lib.optional leveldbSupport pp.leveldb)
@@ -147,7 +147,7 @@ stdenv.mkDerivation rec {
       Center (BVLC) and by community contributors.
     '';
     homepage = "http://caffe.berkeleyvision.org/";
-    maintainers = with maintainers; [ ];
+    maintainers = [ ];
     broken =
       (pythonSupport && (python.isPy310))
       || cudaSupport
diff --git a/pkgs/applications/science/math/cbc/default.nix b/pkgs/applications/science/math/cbc/default.nix
index aa979a78cb485..dbe7b6d241ab5 100644
--- a/pkgs/applications/science/math/cbc/default.nix
+++ b/pkgs/applications/science/math/cbc/default.nix
@@ -27,7 +27,7 @@ stdenv.mkDerivation rec {
   meta = {
     homepage = "https://projects.coin-or.org/Cbc";
     license = lib.licenses.epl10;
-    maintainers = [ lib.maintainers.eelco ];
+    maintainers = [ ];
     platforms = lib.platforms.linux ++ lib.platforms.darwin;
     description = "Mixed integer programming solver";
   };
diff --git a/pkgs/applications/science/math/cemu-ti/default.nix b/pkgs/applications/science/math/cemu-ti/default.nix
index c8d5bea6f602e..547b57b312dbf 100644
--- a/pkgs/applications/science/math/cemu-ti/default.nix
+++ b/pkgs/applications/science/math/cemu-ti/default.nix
@@ -1,39 +1,39 @@
 { stdenv
 , lib
 , fetchFromGitHub
-, qmake
+, cmake
 , pkg-config
-, wrapQtAppsHook
+, qt6
 , libarchive
 , libpng
 }:
 
-stdenv.mkDerivation rec {
+stdenv.mkDerivation (finalAttrs: {
   pname = "CEmu";
-  version = "unstable-2022-06-29";
+  version = "2.0";
   src = fetchFromGitHub {
     owner = "CE-Programming";
     repo = "CEmu";
-    rev = "880d391ba9f8b7b2ec36ab9b45a34e9ecbf744e9";
-    hash = "sha256-aFwGZJceh1jEP8cEajY5wYlSaFuNhYvSoZ/E1QDfJEI=";
+    rev = "v${finalAttrs.version}";
+    hash = "sha256-fohsIJrvPDMmYHoPbmYQlKLMnj/B3XEBaerZYuqxvd8=";
     fetchSubmodules = true;
   };
 
+  sourceRoot = "${finalAttrs.src.name}/gui/qt/";
+
+
   nativeBuildInputs = [
-    qmake
-    wrapQtAppsHook
+    cmake
+    qt6.wrapQtAppsHook
     pkg-config
   ];
 
   buildInputs = [
+    qt6.qtbase
     libarchive
     libpng
   ];
 
-  qmakeFlags = [
-    "gui/qt"
-  ];
-
   meta = with lib; {
     description = "Third-party TI-84 Plus CE / TI-83 Premium CE emulator, focused on developer features";
     mainProgram = "CEmu";
@@ -41,6 +41,6 @@ stdenv.mkDerivation rec {
     license = licenses.gpl3Plus;
     maintainers = with maintainers; [ luc65r ];
     platforms = [ "x86_64-linux" "x86_64-darwin" ];
-    broken = stdenv.isDarwin;
+    broken = stdenv.hostPlatform.isDarwin;
   };
-}
+})
diff --git a/pkgs/applications/science/math/colpack/default.nix b/pkgs/applications/science/math/colpack/default.nix
index 768366cc5d7a5..591ac3281e5e8 100644
--- a/pkgs/applications/science/math/colpack/default.nix
+++ b/pkgs/applications/science/math/colpack/default.nix
@@ -15,7 +15,7 @@ stdenv.mkDerivation rec {
   nativeBuildInputs = [ autoreconfHook ];
 
   configureFlags = [
-    "--enable-openmp=${if stdenv.isLinux then "yes" else "no"}"
+    "--enable-openmp=${if stdenv.hostPlatform.isLinux then "yes" else "no"}"
     "--enable-examples=no"
   ];
 
diff --git a/pkgs/applications/science/math/cplex/default.nix b/pkgs/applications/science/math/cplex/default.nix
index ddc950b30664b..e80444b70b275 100644
--- a/pkgs/applications/science/math/cplex/default.nix
+++ b/pkgs/applications/science/math/cplex/default.nix
@@ -9,14 +9,14 @@
 
 stdenv.mkDerivation rec {
   pname = "cplex";
-  version = "128";
+  version = "22.11";
 
   src =
     if releasePath == null then
       throw ''
         This nix expression requires that the cplex installer is already
         downloaded to your machine. Get it from IBM:
-        https://developer.ibm.com/docloud/blog/2017/12/20/cplex-optimization-studio-12-8-now-available/
+        https://www.ibm.com/support/pages/downloading-ibm-ilog-cplex-optimization-studio-2211
 
         Set `cplex.releasePath = /path/to/download;` in your
         ~/.config/nixpkgs/config.nix for `nix-*` commands, or
@@ -36,7 +36,8 @@ stdenv.mkDerivation rec {
   '';
 
   buildPhase = ''
-    sh $name -i silent -DLICENSE_ACCEPTED=TRUE -DUSER_INSTALL_DIR=$out
+     export JAVA_TOOL_OPTIONS=-Djdk.util.zip.disableZip64ExtraFieldValidation=true
+     sh $name LAX_VM ${openjdk}/bin/java -i silent -DLICENSE_ACCEPTED=TRUE -DUSER_INSTALL_DIR=$out
   '';
 
   installPhase = ''
diff --git a/pkgs/applications/science/math/dap/default.nix b/pkgs/applications/science/math/dap/default.nix
deleted file mode 100644
index 40ce12f66ebd0..0000000000000
--- a/pkgs/applications/science/math/dap/default.nix
+++ /dev/null
@@ -1,37 +0,0 @@
-{ lib
-, stdenv
-, fetchurl
-}:
-
-stdenv.mkDerivation rec {
-  pname = "dap";
-  version = "3.10";
-
-  src = fetchurl {
-    url = "mirror://gnu/${pname}/${pname}-${version}.tar.gz";
-    sha256 = "Bk5sty/438jLb1PpurMQ5OqMbr6JqUuuQjcg2bejh2Y=";
-  };
-
-  hardeningDisable = [ "format" ];
-
-  meta = with lib; {
-    homepage = "https://www.gnu.org/software/dap";
-    description = "Small statistics and graphics package based on C";
-    longDescription = ''
-      Dap is a small statistics and graphics package based on C. Version 3.0 and
-      later of Dap can read SBS programs (based on the utterly famous, industry
-      standard statistics system with similar initials - you know the one I
-      mean)! The user wishing to perform basic statistical analyses is now freed
-      from learning and using C syntax for straightforward tasks, while
-      retaining access to the C-style graphics and statistics features provided
-      by the original implementation. Dap provides core methods of data
-      management, analysis, and graphics that are commonly used in statistical
-      consulting practice (univariate statistics, correlations and regression,
-      ANOVA, categorical data analysis, logistic regression, and nonparametric
-      analyses).
-    '';
-    license = licenses.gpl3Plus;
-    maintainers = with maintainers; [ AndersonTorres ];
-    platforms = platforms.unix;
-  };
-}
diff --git a/pkgs/applications/science/math/ecm/default.nix b/pkgs/applications/science/math/ecm/default.nix
index 222db0e98e6a5..ed1c07d87ec1a 100644
--- a/pkgs/applications/science/math/ecm/default.nix
+++ b/pkgs/applications/science/math/ecm/default.nix
@@ -15,7 +15,7 @@ stdenv.mkDerivation {
   };
 
   # See https://trac.sagemath.org/ticket/19233
-  configureFlags = lib.optional stdenv.isDarwin "--disable-asm-redc";
+  configureFlags = lib.optional stdenv.hostPlatform.isDarwin "--disable-asm-redc";
 
   buildInputs = [ m4 gmp ];
 
diff --git a/pkgs/applications/science/math/eigenmath/default.nix b/pkgs/applications/science/math/eigenmath/default.nix
index a120de87b9ff1..8a3ff56e1f6b9 100644
--- a/pkgs/applications/science/math/eigenmath/default.nix
+++ b/pkgs/applications/science/math/eigenmath/default.nix
@@ -7,13 +7,13 @@
 
 stdenv.mkDerivation rec {
   pname = "eigenmath";
-  version = "3.27-unstable-2024-06-20";
+  version = "3.27-unstable-2024-09-15";
 
   src = fetchFromGitHub {
     owner = "georgeweigt";
     repo = pname;
-    rev = "c3e3da104dbef888c3e52659134d5e9bdc12764d";
-    hash = "sha256-fqCphnRQw79v7ZTCZU9ucm/R7BKY7yCZYDSnxD7uRS8=";
+    rev = "ba00d77289f1c9ce64108b1bbcee02c71ce48633";
+    hash = "sha256-yFzsMNVjQK64uQSfjQKC8LbdQu7/97hDolRMBc4Womc=";
   };
 
   checkPhase = let emulator = stdenv.hostPlatform.emulator buildPackages; in ''
diff --git a/pkgs/applications/science/math/fricas/default.nix b/pkgs/applications/science/math/fricas/default.nix
index 9f0b87f011a10..43a00a5e1fbac 100644
--- a/pkgs/applications/science/math/fricas/default.nix
+++ b/pkgs/applications/science/math/fricas/default.nix
@@ -2,13 +2,13 @@
 
 stdenv.mkDerivation rec {
   pname = "fricas";
-  version = "1.3.10";
+  version = "1.3.11";
 
   src = fetchFromGitHub {
     owner = "fricas";
     repo = "fricas";
     rev = version;
-    sha256 = "sha256-T1xDndDnHq/hmhTWWO3Eu0733u8+C8sJMCF6pbLU2GI=";
+    sha256 = "sha256-EX/boSs6rK4RrJ5W6Rd0TSHsbQsNiFI1evFuNPBMeu8=";
   };
 
   buildInputs = [ sbcl libX11 libXpm libICE libSM libXt libXau libXdmcp ];
diff --git a/pkgs/applications/science/math/gap/default.nix b/pkgs/applications/science/math/gap/default.nix
index 7a466f8c000c5..697a19d6afa19 100644
--- a/pkgs/applications/science/math/gap/default.nix
+++ b/pkgs/applications/science/math/gap/default.nix
@@ -1,5 +1,6 @@
 { stdenv
 , lib
+, fetchpatch
 , fetchurl
 , makeWrapper
 , readline
@@ -73,6 +74,13 @@ stdenv.mkDerivation rec {
     sha256 = "sha256-ZyMIdF63iiIklO6N1nhu3VvDMUVvzGRWrAZL2yjVh6g=";
   };
 
+  patches = [
+    (fetchpatch {
+      url = "https://github.com/gap-system/gap/commit/c786e229413a44b7462196716b99ae9bb0071f4c.patch";
+      hash = "sha256-g3jrEMSavHAUKlHoPqWmOw49hWHU+29SA788Klnr0Uw=";
+    })
+  ];
+
   # remove all non-essential packages (which take up a lot of space)
   preConfigure = lib.optionalString (!keepAll) (removeNonWhitelistedPkgs packagesToKeep) + ''
     patchShebangs .
diff --git a/pkgs/applications/science/math/geogebra/default.nix b/pkgs/applications/science/math/geogebra/default.nix
index 5fa4862bb9b40..1d5fa4a9ef450 100644
--- a/pkgs/applications/science/math/geogebra/default.nix
+++ b/pkgs/applications/science/math/geogebra/default.nix
@@ -95,6 +95,6 @@ let
     '';
   };
 in
-if stdenv.isDarwin
+if stdenv.hostPlatform.isDarwin
 then darwinPkg
 else linuxPkg
diff --git a/pkgs/applications/science/math/geogebra/geogebra6.nix b/pkgs/applications/science/math/geogebra/geogebra6.nix
index 38b668804ad16..d57175daff93e 100644
--- a/pkgs/applications/science/math/geogebra/geogebra6.nix
+++ b/pkgs/applications/science/math/geogebra/geogebra6.nix
@@ -1,4 +1,12 @@
-{ lib, stdenv, unzip, fetchurl, electron, makeWrapper, geogebra }:
+{
+  lib,
+  stdenv,
+  unzip,
+  fetchurl,
+  electron,
+  makeWrapper,
+  geogebra,
+}:
 let
   pname = "geogebra";
   version = "6-0-794-0";
@@ -14,14 +22,17 @@ let
       calculus in one easy-to-use package.
     '';
     homepage = "https://www.geogebra.org/";
-    maintainers = with maintainers; [ voidless sikmir ];
+    maintainers = with maintainers; [
+      voidless
+      sikmir
+    ];
     license = licenses.geogebra;
     sourceProvenance = with sourceTypes; [
       binaryBytecode
-      binaryNativeCode  # some jars include native binaries
+      binaryNativeCode # some jars include native binaries
     ];
     platforms = with platforms; linux ++ darwin;
-    hydraPlatforms = [];
+    hydraPlatforms = [ ];
   };
 
   linuxPkg = stdenv.mkDerivation {
@@ -50,7 +61,9 @@ let
     installPhase = ''
       mkdir -p $out/libexec/geogebra/ $out/bin
       cp -r GeoGebra-linux-x64/{resources,locales} "$out/"
-      makeWrapper ${lib.getBin electron}/bin/electron $out/bin/geogebra --add-flags "$out/resources/app"
+      makeWrapper ${lib.getBin electron}/bin/electron $out/bin/geogebra \
+        --add-flags "$out/resources/app" \
+        --add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--ozone-platform-hint=auto --enable-features=WaylandWindowDecorations}}"
       install -Dm644 "${desktopItem}/share/applications/"* \
         -t $out/share/applications/
 
@@ -84,6 +97,4 @@ let
     };
   };
 in
-if stdenv.isDarwin
-then darwinPkg
-else linuxPkg
+if stdenv.hostPlatform.isDarwin then darwinPkg else linuxPkg
diff --git a/pkgs/applications/science/math/getdp/default.nix b/pkgs/applications/science/math/getdp/default.nix
index 8accf9d76725a..30a5837c3111d 100644
--- a/pkgs/applications/science/math/getdp/default.nix
+++ b/pkgs/applications/science/math/getdp/default.nix
@@ -1,6 +1,8 @@
 { lib, stdenv, fetchurl, cmake, gfortran, blas, lapack, mpi, petsc, python3 }:
 
-stdenv.mkDerivation rec {
+let
+  mpiSupport = petsc.passthru.mpiSupport;
+in stdenv.mkDerivation rec {
   pname = "getdp";
   version = "3.6.0";
   src = fetchurl {
@@ -8,7 +10,6 @@ stdenv.mkDerivation rec {
     hash = "sha256-nzefwCV+Z9BHDofuTfhR+vhqm3cCSiUT+7cbtn601N8=";
   };
 
-  inherit (petsc) mpiSupport;
   nativeBuildInputs = [ cmake python3 ];
   buildInputs = [ gfortran blas lapack petsc ]
     ++ lib.optional mpiSupport mpi
@@ -27,7 +28,7 @@ stdenv.mkDerivation rec {
     '';
     homepage = "http://getdp.info/";
     license = licenses.gpl2Plus;
-    maintainers = with maintainers; [ ];
+    maintainers = [ ];
     platforms = platforms.linux;
   };
 }
diff --git a/pkgs/applications/science/math/gfan/default.nix b/pkgs/applications/science/math/gfan/default.nix
index ee1fce783d265..531a30e3f857f 100644
--- a/pkgs/applications/science/math/gfan/default.nix
+++ b/pkgs/applications/science/math/gfan/default.nix
@@ -1,4 +1,4 @@
-{lib, stdenv, fetchurl, gmp, mpir, cddlib}:
+{lib, stdenv, fetchpatch, fetchurl, gmp, mpir, cddlib}:
 stdenv.mkDerivation rec {
   pname = "gfan";
   version = "0.6.2";
@@ -10,6 +10,12 @@ stdenv.mkDerivation rec {
 
   patches = [
     ./gfan-0.6.2-cddlib-prefix.patch
+  ] ++ lib.optionals (stdenv.cc.isClang) [
+    (fetchpatch {
+      name = "clang-fix-miscompilation.patch";
+      url = "https://raw.githubusercontent.com/sagemath/sage/eea1f59394a5066e9acd8ae39a90302820914ee3/build/pkgs/gfan/patches/nodel.patch";
+      sha256 = "sha256-RrncSgFyrBIk/Bwe3accxiJ2rpOSJKQ84cV/uBvQsDc=";
+    })
   ];
 
   postPatch = lib.optionalString stdenv.cc.isClang ''
diff --git a/pkgs/applications/science/math/giac/default.nix b/pkgs/applications/science/math/giac/default.nix
index 834ae7b3d61f3..ce009975c1ba1 100644
--- a/pkgs/applications/science/math/giac/default.nix
+++ b/pkgs/applications/science/math/giac/default.nix
@@ -9,18 +9,30 @@ assert (!blas.isILP64) && (!lapack.isILP64);
 
 stdenv.mkDerivation rec {
   pname = "giac${lib.optionalString enableGUI "-with-xcas"}";
-  version = "1.9.0-43"; # TODO try to remove preCheck phase on upgrade
+  version = "1.9.0-993"; # TODO try to remove preCheck phase on upgrade
 
   src = fetchurl {
     url = "https://www-fourier.ujf-grenoble.fr/~parisse/debian/dists/stable/main/source/giac_${version}.tar.gz";
-    sha256 = "sha256-466jB8ZRqHkU5XCY+j0Fh7Dq/mMaOu10rHECKbtNGrs=";
+    sha256 = "sha256-pqytFWrSWfEwQqRdRbaigGCq68s8mdgj2j8M+kclslE=";
   };
 
   patches = [
+    ./remove-old-functional-patterns.patch
+    ./fix-fltk-guard.patch
+
+    (fetchpatch {
+      name = "pari_2_15.patch";
+      url = "https://raw.githubusercontent.com/sagemath/sage/07a2afd65fb4b0a1c9cbc43ede7d4a18c921a000/build/pkgs/giac/patches/pari_2_15.patch";
+      sha256 = "sha256-Q3xBFED7XEAyNz6AHjzt63XtospmdGAIdS6iPq1C2UE=";
+    })
+
     (fetchpatch {
-      name = "pari_2_11.patch";
-      url = "https://raw.githubusercontent.com/sagemath/sage/21ba7540d385a9864b44850d6987893dfa16bfc0/build/pkgs/giac/patches/pari_2_11.patch";
-      sha256 = "sha256-vEo/5MNzMdYRPWgLFPsDcMT1W80Qzj4EPBjx/B8j68k=";
+      name = "infinity.patch";
+      url = "https://github.com/geogebra/giac/commit/851c2cd91e879c79d6652f8a5d5bed03b65c6d39.patch";
+      sha256 = "sha256-WJRT2b8I9kgAkRuIugMiXoF4hT7yR7qyad8A6IspNTM=";
+      stripLen = 5;
+      extraPrefix = "/src/";
+      excludes = [ "src/kdisplay.cc" ];
     })
 
     # giac calls scanf/printf with non-constant first arguments, which
@@ -31,8 +43,12 @@ stdenv.mkDerivation rec {
       sha256 = "sha256-r+M+9MRPRqhHcdhYWI6inxyNvWbXUbBcPCeDY7aulvk=";
     })
 
-    # increase pari stack size for test chk_fhan{4,6}
-    ./increase-pari-stack-size.patch
+    # issue with include path precedence
+    (fetchpatch {
+      name = "fix_implicit_declaration.patch";
+      url = "https://salsa.debian.org/science-team/giac/-/raw/c05ae9b9e74d3c6ee6411d391071989426a76201/debian/patches/fix_implicit_declaration.patch";
+      sha256 = "sha256-ompUceYJLiL0ftfjBkIMcYvX1YqG2/XA7e1yDyFY0IY=";
+    })
   ] ++ lib.optionals (!enableGUI) [
     # when enableGui is false, giac is compiled without fltk. That
     # means some outputs differ in the make check. Patch around this:
@@ -86,6 +102,12 @@ stdenv.mkDerivation rec {
     # when fltk is disabled. disable these tests for now.
     echo > check/chk_fhan2
     echo > check/chk_fhan9
+  '' + lib.optionalString (stdenv.hostPlatform.isDarwin) ''
+    # these cover a known regression in giac, likely due to how pari state
+    # is shared between multiple giac instances (see pari.cc.old).
+    # see https://github.com/NixOS/nixpkgs/pull/264126 for more information
+    echo > check/chk_fhan4
+    echo > check/chk_fhan6
   '';
 
   enableParallelBuilding = true;
@@ -96,6 +118,8 @@ stdenv.mkDerivation rec {
     "--enable-ao" "--enable-ecm" "--enable-glpk"
   ] ++ lib.optionals enableGUI [
     "--enable-gui" "--with-x"
+  ] ++ lib.optionals stdenv.hostPlatform.isDarwin [
+    "--disable-nls"
   ] ++ lib.optionals (!enableGUI) [
     "--disable-fltk"
   ] ++ lib.optionals (!enableMicroPy) [
@@ -129,7 +153,6 @@ stdenv.mkDerivation rec {
     homepage = "https://www-fourier.ujf-grenoble.fr/~parisse/giac.html";
     license = licenses.gpl3Plus;
     platforms = platforms.linux ++ (optionals (!enableGUI) platforms.darwin);
-    broken = stdenv.isDarwin && stdenv.isAarch64;
     maintainers = [ maintainers.symphorien ];
   };
 }
diff --git a/pkgs/applications/science/math/giac/fix-fltk-guard.patch b/pkgs/applications/science/math/giac/fix-fltk-guard.patch
new file mode 100644
index 0000000000000..a9c8e5bbaab8d
--- /dev/null
+++ b/pkgs/applications/science/math/giac/fix-fltk-guard.patch
@@ -0,0 +1,28 @@
+From c7eafa2d7bde0d735b125912542acec2d5896c17 Mon Sep 17 00:00:00 2001
+From: George Huebner <george@feyor.sh>
+Date: Sat, 20 Jul 2024 02:31:20 -0500
+Subject: [PATCH 3/4] remove erroneous HAVE_LIBFLTK guard
+
+---
+ src/icas.cc | 4 ----
+ 1 file changed, 4 deletions(-)
+
+diff --git a/src/icas.cc b/src/icas.cc
+index f91885b..17a0373 100644
+--- a/src/icas.cc
++++ b/src/icas.cc
+@@ -2407,11 +2407,7 @@ int main(int ARGC, char *ARGV[]){
+ #ifdef __APPLE__
+       startc=clock();
+ #endif
+-#ifdef HAVE_LIBFLTK
+       xcas::icas_eval(gq,e,reading_file,filename,contextptr);
+-#else
+-      e=eval(gq,1,contextptr);
+-#endif
+ #ifdef __APPLE__
+       startc=clock()-startc;
+ #endif
+-- 
+2.44.1
+
diff --git a/pkgs/applications/science/math/giac/increase-pari-stack-size.patch b/pkgs/applications/science/math/giac/increase-pari-stack-size.patch
deleted file mode 100644
index b12b4b7fad660..0000000000000
--- a/pkgs/applications/science/math/giac/increase-pari-stack-size.patch
+++ /dev/null
@@ -1,18 +0,0 @@
-diff -ur a/check/chk_fhan4 b/check/chk_fhan4
---- a/check/chk_fhan4	2018-03-13 19:27:11.000000000 +0100
-+++ b/check/chk_fhan4	2023-05-20 16:31:30.349063063 +0200
-@@ -1,4 +1,5 @@
- #! /bin/sh
- unset LANG
-+export PARI_SIZE=2048000
- ../src/icas TP04-sol.cas > TP04.tst
- diff TP04.tst TP04-sol.cas.out1
-diff -ur a/check/chk_fhan6 b/check/chk_fhan6
---- a/check/chk_fhan6	2018-03-13 19:27:21.000000000 +0100
-+++ b/check/chk_fhan6	2023-05-20 16:32:04.199407065 +0200
-@@ -1,4 +1,5 @@
- #! /bin/sh
- unset LANG
-+export PARI_SIZE=2048000
- ../src/icas TP06-sol.cas > TP06.tst
- diff TP06.tst TP06-sol.cas.out1
diff --git a/pkgs/applications/science/math/giac/remove-old-functional-patterns.patch b/pkgs/applications/science/math/giac/remove-old-functional-patterns.patch
new file mode 100644
index 0000000000000..95f6efe119fcb
--- /dev/null
+++ b/pkgs/applications/science/math/giac/remove-old-functional-patterns.patch
@@ -0,0 +1,294 @@
+From f1c5309d5b815acc2616cd9fbb5182b1e64d225f Mon Sep 17 00:00:00 2001
+From: George Huebner <george@feyor.sh>
+Date: Wed, 17 Jul 2024 18:12:36 -0500
+Subject: [PATCH 1/4] remove old <functional> patterns
+
+pointer_to_binary_function and ptr_fun are holdovers from pre c++11,
+and can be replaced or entirely removed. This allows Giac to compile
+with Clang 16>=.
+---
+ src/all_global_var |  2 +-
+ src/gausspol.cc    |  2 +-
+ src/gausspol.h     |  2 +-
+ src/gen.cc         |  2 +-
+ src/gen.h          |  4 ++--
+ src/maple.cc       |  2 +-
+ src/monomial.h     | 16 ++++++++--------
+ src/plot.cc        |  2 +-
+ src/poly.h         | 17 +++++++++--------
+ src/solve.cc       | 18 +++++++++---------
+ src/usual.cc       |  2 +-
+ 11 files changed, 35 insertions(+), 34 deletions(-)
+
+diff --git a/src/all_global_var b/src/all_global_var
+index 7d75d73..55f4782 100644
+--- a/src/all_global_var
++++ b/src/all_global_var
+@@ -16,7 +16,7 @@ Relatif a l'evaluation du tableur
+ // File Eqw.cc
+   vector<string> completion_tab;
+ // File alg_ext.cc
+-  rootmap symbolic_rootof_list(ptr_fun(islesscomplex));
++  rootmap symbolic_rootof_list(islesscomplex);
+ // File derive.cc
+ // File desolve.cc
+   identificateur laplace_var(" s");
+diff --git a/src/gausspol.cc b/src/gausspol.cc
+index 8fbd581..2f2121f 100644
+--- a/src/gausspol.cc
++++ b/src/gausspol.cc
+@@ -855,7 +855,7 @@ namespace giac {
+ 		 std::vector< monomial<gen> >::const_iterator & itb_end,
+ 		 std::vector< monomial<gen> > & new_coord,
+ 		 bool (* is_strictly_greater)( const index_m &, const index_m &),
+-		 const std::pointer_to_binary_function < const monomial<gen> &, const monomial<gen> &, bool> m_is_strictly_greater
++		 const std::function<bool(const monomial<gen> &, const monomial<gen> &)> m_is_strictly_greater
+ 	     ) {
+     if (ita==ita_end || itb==itb_end){
+       new_coord.clear();
+diff --git a/src/gausspol.h b/src/gausspol.h
+index b5d214b..e6c7e0c 100644
+--- a/src/gausspol.h
++++ b/src/gausspol.h
+@@ -93,7 +93,7 @@ namespace giac {
+ 		 std::vector< monomial<gen> >::const_iterator & itb_end,
+ 		 std::vector< monomial<gen> > & new_coord,
+ 		 bool (* is_strictly_greater)( const index_t &, const index_t &),
+-		 const std::pointer_to_binary_function < const monomial<gen> &, const monomial<gen> &, bool> m_is_greater
++         const std::function<bool(const monomial<gen> &, const monomial<gen> &)> m_is_greater
+ 		 ) ;
+   void mulpoly(const polynome & th,const gen & fact,polynome & res);
+   polynome operator * (const polynome & th, const gen & fact) ;
+diff --git a/src/gen.cc b/src/gen.cc
+index 7d4874c..0b64afe 100644
+--- a/src/gen.cc
++++ b/src/gen.cc
+@@ -1126,7 +1126,7 @@ namespace giac {
+ #if 1 // def NSPIRE
+       g.__MAPptr = new ref_gen_map;
+ #else
+-    g.__MAPptr = new ref_gen_map(ptr_fun(islesscomplexthanf));
++    g.__MAPptr = new ref_gen_map(islesscomplexthanf);
+ #endif
+ #endif
+     g.type=_MAP;
+diff --git a/src/gen.h b/src/gen.h
+index 04d70af..496b25d 100644
+--- a/src/gen.h
++++ b/src/gen.h
+@@ -443,7 +443,7 @@ namespace giac {
+   };
+   typedef std::map<gen,gen,comparegen> gen_map;
+ #else
+-  typedef std::map<gen,gen,const std::pointer_to_binary_function < const gen &, const gen &, bool> > gen_map;
++    typedef std::map<gen,gen,const std::function<bool(const gen &, const gen &)> > gen_map;
+ #endif
+   struct ref_gen_map;
+ 
+@@ -902,7 +902,7 @@ namespace giac {
+ #if 1 // def NSPIRE
+     ref_gen_map(): ref_count(1),m() {}
+ #else
+-    ref_gen_map(const std::pointer_to_binary_function < const gen &, const gen &, bool> & p): ref_count(1),m(p) {}
++    ref_gen_map(const std::function<bool(const gen &, const gen &)> & p): ref_count(1),m(p) {}
+ #endif
+     ref_gen_map(const gen_map & M):ref_count(1),m(M) {}
+   };
+diff --git a/src/maple.cc b/src/maple.cc
+index 3b33da8..d57a170 100644
+--- a/src/maple.cc
++++ b/src/maple.cc
+@@ -3626,7 +3626,7 @@ namespace giac {
+ #if 1 // def NSPIRE
+     gen_map m;
+ #else
+-    gen_map m(ptr_fun(islessthanf));
++    gen_map m(islessthanf);
+ #endif
+     int s=int(args.size());
+     vector<int> indexbegin,indexsize;
+diff --git a/src/monomial.h b/src/monomial.h
+index 6e606d0..637a76c 100644
+--- a/src/monomial.h
++++ b/src/monomial.h
+@@ -338,9 +338,9 @@ namespace giac {
+ 
+   template<class T> class sort_helper {
+   public:
+-    std::pointer_to_binary_function < const monomial<T> &, const monomial<T> &, bool> strictly_greater ;
+-    sort_helper(const std::pointer_to_binary_function < const monomial<T> &, const monomial<T> &, bool> is_strictly_greater):strictly_greater(is_strictly_greater) {};
+-    sort_helper():strictly_greater(std::ptr_fun<const monomial<T> &, const monomial<T> &, bool>(m_lex_is_strictly_greater<T>)) {};
++    std::function<bool(const monomial<T> &, const monomial<T> &)> strictly_greater ;
++      sort_helper(const std::function<bool(const monomial<T> &, const monomial<T> &)> is_strictly_greater):strictly_greater(is_strictly_greater) {};
++    sort_helper():strictly_greater(m_lex_is_strictly_greater<T>) {};
+     bool operator () (const monomial<T> & a, const monomial<T> & b){ return strictly_greater(a,b);}
+   };
+ 
+@@ -677,7 +677,7 @@ namespace giac {
+ 	     typename std::vector< monomial<T> >::const_iterator & itb_end,
+ 	     std::vector< monomial<T> > & new_coord,
+ 	     bool (* is_strictly_greater)( const index_m &, const index_m &),
+-	     const std::pointer_to_binary_function < const monomial<T> &, const monomial<T> &, bool> m_is_strictly_greater
++	     const std::function<bool(const monomial<T> &, const monomial<T> &)> m_is_strictly_greater
+ 	     ) {
+     if (ita==ita_end || itb==itb_end){
+       new_coord.clear();
+@@ -726,8 +726,8 @@ namespace giac {
+ #endif
+ #ifndef NSPIRE
+     /* other algorithm using a map to avoid reserving too much space */
+-    typedef std::map< index_t,T,const std::pointer_to_binary_function < const index_m &, const index_m &, bool> > application;
+-    application produit(std::ptr_fun(is_strictly_greater));
++    typedef std::map< index_t,T,const std::function<bool(const index_m &, const index_m &)> > application;
++    application produit(is_strictly_greater);
+     // typedef std::map<index_t,T> application;
+     // application produit;
+     index_t somme(ita->index.size());
+@@ -848,7 +848,7 @@ namespace giac {
+     typename std::vector< monomial<T> >::const_iterator a=v.begin(), a_end=v.end();
+     typename std::vector< monomial<T> >::const_iterator b=w.begin(), b_end=w.end();
+     std::vector< monomial<T> > res;
+-    Mul(a,a_end,b,b_end,res,i_lex_is_strictly_greater,std::ptr_fun< const monomial<T> &, const monomial<T> &, bool >((m_lex_is_strictly_greater<T>)));
++    Mul(a,a_end,b,b_end,res,i_lex_is_strictly_greater,m_lex_is_strictly_greater<T>);
+     return res ;
+   }
+ 
+@@ -856,7 +856,7 @@ namespace giac {
+   std::vector< monomial<T> > & operator *= (std::vector< monomial<T> > & v,const std::vector< monomial<T> > & w){
+     typename std::vector< monomial<T> >::const_iterator a=v.begin(), a_end=v.end();
+     typename std::vector< monomial<T> >::const_iterator b=w.begin(), b_end=w.end();
+-    Mul(a,a_end,b,b_end,v,i_lex_is_strictly_greater,std::ptr_fun< const monomial<T> &, const monomial<T> &, bool >((m_lex_is_strictly_greater<T>)));
++    Mul(a,a_end,b,b_end,v,i_lex_is_strictly_greater,m_lex_is_strictly_greater<T>);
+     return v;
+   }
+ 
+diff --git a/src/plot.cc b/src/plot.cc
+index 288a1b5..ac85c9a 100755
+--- a/src/plot.cc
++++ b/src/plot.cc
+@@ -11886,7 +11886,7 @@ static vecteur densityscale(double xmin,double xmax,double ymin,double ymax,doub
+ #if 1 // def NSPIRE
+     gen_map m;
+ #else
+-    gen_map m(ptr_fun(islesscomplexthanf));
++    gen_map m(islesscomplexthanf);
+ #endif
+     int taille;
+     is >> taille;
+diff --git a/src/poly.h b/src/poly.h
+index 7d64e2c..d9ff991 100644
+--- a/src/poly.h
++++ b/src/poly.h
+@@ -40,23 +40,24 @@ namespace giac {
+     // T zero;
+     // functional object sorting function for monomial ordering
+     bool (* is_strictly_greater)( const index_m &, const index_m &);
+-    std::pointer_to_binary_function < const monomial<T> &, const monomial<T> &, bool> m_is_strictly_greater ;
++    std::function<bool(const monomial<T> &, const monomial<T> &)> m_is_strictly_greater ;
+     // constructors
+     tensor(const tensor<T> & t) : dim(t.dim), coord(t.coord), is_strictly_greater(t.is_strictly_greater), m_is_strictly_greater(t.m_is_strictly_greater) { }
+     tensor(const tensor<T> & t, const std::vector< monomial<T> > & v) : dim(t.dim), coord(v), is_strictly_greater(t.is_strictly_greater), m_is_strictly_greater(t.m_is_strictly_greater) { }
+     // warning: this constructor prohibits construction of tensor from a value
+     // of type T if this value is an int, except by using tensor<T>(T(int))
+-    tensor() : dim(0), is_strictly_greater(i_lex_is_strictly_greater), m_is_strictly_greater(std::ptr_fun<const monomial<T> &, const monomial<T> &, bool>(m_lex_is_strictly_greater<T>)) { }
+-    explicit tensor(int d) : dim(d), is_strictly_greater(i_lex_is_strictly_greater), m_is_strictly_greater(std::ptr_fun<const monomial<T> &, const monomial<T> &, bool>(m_lex_is_strictly_greater<T>)) { }
++    // DANGER
++    tensor() : dim(0), is_strictly_greater(i_lex_is_strictly_greater), m_is_strictly_greater(m_lex_is_strictly_greater<T>) { }
++    explicit tensor(int d) : dim(d), is_strictly_greater(i_lex_is_strictly_greater), m_is_strictly_greater(m_lex_is_strictly_greater<T>) { }
+     explicit tensor(int d,const tensor<T> & t) : dim(d),is_strictly_greater(t.is_strictly_greater), m_is_strictly_greater(t.m_is_strictly_greater)  { }
+-    tensor(const monomial<T> & v) : dim(int(v.index.size())), is_strictly_greater(i_lex_is_strictly_greater), m_is_strictly_greater(std::ptr_fun<const monomial<T> &, const monomial<T> &, bool>(m_lex_is_strictly_greater<T>)) { 
++    tensor(const monomial<T> & v) : dim(int(v.index.size())), is_strictly_greater(i_lex_is_strictly_greater), m_is_strictly_greater(m_lex_is_strictly_greater<T>) { 
+       coord.push_back(v);
+     }
+-    tensor(const T & v, int d) : dim(d), is_strictly_greater(i_lex_is_strictly_greater), m_is_strictly_greater(std::ptr_fun<const monomial<T> &, const monomial<T> &, bool>(m_lex_is_strictly_greater<T>)) {
++    tensor(const T & v, int d) : dim(d), is_strictly_greater(i_lex_is_strictly_greater), m_is_strictly_greater(m_lex_is_strictly_greater<T>) {
+       if (!is_zero(v))
+ 	coord.push_back(monomial<T>(v,0,d));
+     }
+-    tensor(int d,const std::vector< monomial<T> > & c) : dim(d), coord(c), is_strictly_greater(i_lex_is_strictly_greater),m_is_strictly_greater(std::ptr_fun<const monomial<T> &, const monomial<T> &, bool>(m_lex_is_strictly_greater<T>)) { }
++    tensor(int d,const std::vector< monomial<T> > & c) : dim(d), coord(c), is_strictly_greater(i_lex_is_strictly_greater),m_is_strictly_greater(m_lex_is_strictly_greater<T>) { }
+     ~tensor() { coord.clear(); }
+     // member functions
+     // ordering monomials in the tensor
+@@ -519,10 +520,10 @@ namespace giac {
+   template <class T>
+   void lexsort(std::vector < monomial<T> > & v){
+ #if 1 // def NSPIRE
+-    sort_helper<T> M(std::ptr_fun<const monomial<T> &, const monomial<T> &, bool>(m_lex_is_strictly_greater<T>));
++    sort_helper<T> M(m_lex_is_strictly_greater<T>);
+     sort(v.begin(),v.end(),M);
+ #else
+-    sort(v.begin(),v.end(),std::ptr_fun<const monomial<T> &, const monomial<T> &, bool>(m_lex_is_strictly_greater<T>));
++    sort(v.begin(),v.end(),m_lex_is_strictly_greater<T>);
+ #endif
+   }
+ 
+diff --git a/src/solve.cc b/src/solve.cc
+index 889f824..2a51ab8 100755
+--- a/src/solve.cc
++++ b/src/solve.cc
+@@ -8684,39 +8684,39 @@ namespace giac {
+     switch (order.val){
+     case _PLEX_ORDER: 
+       p.is_strictly_greater=i_lex_is_strictly_greater;
+-      p.m_is_strictly_greater=std::ptr_fun(m_lex_is_strictly_greater<gen>);
++      p.m_is_strictly_greater=m_lex_is_strictly_greater<gen>;
+       break;
+     case _REVLEX_ORDER: 
+       p.is_strictly_greater=i_total_revlex_is_strictly_greater;
+-      p.m_is_strictly_greater=std::ptr_fun(m_total_revlex_is_strictly_greater<gen>);
++      p.m_is_strictly_greater=m_total_revlex_is_strictly_greater<gen>;
+       break;
+     case _TDEG_ORDER:
+       p.is_strictly_greater=i_total_lex_is_strictly_greater;
+-      p.m_is_strictly_greater=std::ptr_fun(m_total_lex_is_strictly_greater<gen>);
++      p.m_is_strictly_greater=m_total_lex_is_strictly_greater<gen>;
+       break;
+     case _3VAR_ORDER:
+       p.is_strictly_greater=i_3var_is_strictly_greater;
+-      p.m_is_strictly_greater=std::ptr_fun(m_3var_is_strictly_greater<gen>);
++      p.m_is_strictly_greater=m_3var_is_strictly_greater<gen>;
+       break;      
+     case _7VAR_ORDER:
+       p.is_strictly_greater=i_7var_is_strictly_greater;
+-      p.m_is_strictly_greater=std::ptr_fun(m_7var_is_strictly_greater<gen>);
++      p.m_is_strictly_greater=m_7var_is_strictly_greater<gen>;
+       break;      
+     case _11VAR_ORDER:
+       p.is_strictly_greater=i_11var_is_strictly_greater;
+-      p.m_is_strictly_greater=std::ptr_fun(m_11var_is_strictly_greater<gen>);
++      p.m_is_strictly_greater=m_11var_is_strictly_greater<gen>;
+       break;      
+     case _16VAR_ORDER:
+       p.is_strictly_greater=i_16var_is_strictly_greater;
+-      p.m_is_strictly_greater=std::ptr_fun(m_16var_is_strictly_greater<gen>);
++      p.m_is_strictly_greater=m_16var_is_strictly_greater<gen>;
+       break;      
+     case _32VAR_ORDER:
+       p.is_strictly_greater=i_32var_is_strictly_greater;
+-      p.m_is_strictly_greater=std::ptr_fun(m_32var_is_strictly_greater<gen>);
++      p.m_is_strictly_greater=m_32var_is_strictly_greater<gen>;
+       break;      
+     case _64VAR_ORDER:
+       p.is_strictly_greater=i_64var_is_strictly_greater;
+-      p.m_is_strictly_greater=std::ptr_fun(m_64var_is_strictly_greater<gen>);
++      p.m_is_strictly_greater=m_64var_is_strictly_greater<gen>;
+       break;      
+     }
+     p.tsort();
+diff --git a/src/usual.cc b/src/usual.cc
+index fddede6..eb7ae5e 100755
+--- a/src/usual.cc
++++ b/src/usual.cc
+@@ -5950,7 +5950,7 @@ namespace giac {
+ #if 1 // def NSPIRE
+     gen_map m;
+ #else
+-    gen_map m(ptr_fun(islesscomplexthanf));
++    gen_map m(islesscomplexthanf);
+ #endif
+     for (;it!=itend;++it){
+       if (is_equal(*it) || it->is_symb_of_sommet(at_deuxpoints)){
+-- 
+2.44.1
+
diff --git a/pkgs/applications/science/math/ginac/default.nix b/pkgs/applications/science/math/ginac/default.nix
index d9d12cbf388de..d2713befed382 100644
--- a/pkgs/applications/science/math/ginac/default.nix
+++ b/pkgs/applications/science/math/ginac/default.nix
@@ -12,7 +12,7 @@ stdenv.mkDerivation rec {
   propagatedBuildInputs = [ cln ];
 
   buildInputs = [ readline ]
-    ++ lib.optional stdenv.isDarwin gmp;
+    ++ lib.optional stdenv.hostPlatform.isDarwin gmp;
 
   nativeBuildInputs = [ pkg-config python3 ];
 
diff --git a/pkgs/applications/science/math/glsurf/default.nix b/pkgs/applications/science/math/glsurf/default.nix
index 38caee5805b43..0edaa32babd70 100644
--- a/pkgs/applications/science/math/glsurf/default.nix
+++ b/pkgs/applications/science/math/glsurf/default.nix
@@ -5,7 +5,7 @@
 , makeWrapper
 , libGLU
 , libGL
-, freeglut
+, libglut
 , mpfr
 , gmp
 , pkgsHostTarget
@@ -32,7 +32,7 @@ stdenv.mkDerivation rec {
   ]);
 
   buildInputs = [
-    freeglut
+    libglut
     libGL
     libGLU
     mpfr
diff --git a/pkgs/applications/science/math/gmsh/default.nix b/pkgs/applications/science/math/gmsh/default.nix
index 3e88e7f94bbe6..2219815824e7c 100644
--- a/pkgs/applications/science/math/gmsh/default.nix
+++ b/pkgs/applications/science/math/gmsh/default.nix
@@ -16,7 +16,7 @@ stdenv.mkDerivation rec {
 
   buildInputs = [
     blas lapack gmm fltk libjpeg zlib opencascade-occt
-  ] ++ lib.optionals (!stdenv.isDarwin) [
+  ] ++ lib.optionals (!stdenv.hostPlatform.isDarwin) [
     libGL libGLU xorg.libXrender xorg.libXcursor xorg.libXfixes
     xorg.libXext xorg.libXft xorg.libXinerama xorg.libX11 xorg.libSM
     xorg.libICE
diff --git a/pkgs/applications/science/math/gurobi/default.nix b/pkgs/applications/science/math/gurobi/default.nix
index e8f4794d4179d..eff61579a5f99 100644
--- a/pkgs/applications/science/math/gurobi/default.nix
+++ b/pkgs/applications/science/math/gurobi/default.nix
@@ -2,11 +2,11 @@
 
 stdenv.mkDerivation rec {
   pname = "gurobi";
-  version = "11.0.2";
+  version = "11.0.3";
 
   src = fetchurl {
     url = "https://packages.gurobi.com/${lib.versions.majorMinor version}/gurobi${version}_linux64.tar.gz";
-    hash = "sha256-9DrIo+25h7mgphRSrNnY2+nrNzaMbafONuUkfLKho2g=";
+    hash = "sha256-gqLIZxwjS7qp3GTaIrGVGr9BxiBH/fdwBOZfJKkd/RM=";
   };
 
   sourceRoot = "gurobi${builtins.replaceStrings ["."] [""] version}/linux64";
diff --git a/pkgs/applications/science/math/lp_solve/default.nix b/pkgs/applications/science/math/lp_solve/default.nix
index 773f1f3c089e4..67d7bfdba90c2 100644
--- a/pkgs/applications/science/math/lp_solve/default.nix
+++ b/pkgs/applications/science/math/lp_solve/default.nix
@@ -15,16 +15,16 @@ stdenv.mkDerivation rec {
     sha256 = "sha256-bUq/9cxqqpM66ObBeiJt8PwLZxxDj2lxXUHQn+gfkC8=";
   };
 
-  nativeBuildInputs = lib.optionals stdenv.isDarwin [
+  nativeBuildInputs = lib.optionals stdenv.hostPlatform.isDarwin [
     cctools
     fixDarwinDylibNames
-  ] ++ lib.optionals (stdenv.isDarwin && stdenv.isAarch64) [
+  ] ++ lib.optionals (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isAarch64) [
     autoSignDarwinBinariesHook
   ];
 
   env = {
     NIX_CFLAGS_COMPILE = "-Wno-error=implicit-int";
-  } // lib.optionalAttrs (stdenv.isDarwin && stdenv.isx86_64) {
+  } // lib.optionalAttrs (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isx86_64) {
     NIX_LDFLAGS = "-headerpad_max_install_names";
   };
 
@@ -32,7 +32,7 @@ stdenv.mkDerivation rec {
 
   buildPhase =
     let
-      ccc = if stdenv.isDarwin then "ccc.osx" else "ccc";
+      ccc = if stdenv.hostPlatform.isDarwin then "ccc.osx" else "ccc";
     in
     ''
       runHook preBuild
diff --git a/pkgs/applications/science/math/mathematica/10.nix b/pkgs/applications/science/math/mathematica/10.nix
deleted file mode 100644
index e5ab259b8f70b..0000000000000
--- a/pkgs/applications/science/math/mathematica/10.nix
+++ /dev/null
@@ -1,132 +0,0 @@
-{ lib
-, patchelf
-, requireFile
-, stdenv
-# arguments from default.nix
-, lang
-, meta
-, name
-, src
-, version
-# dependencies
-, alsa-lib
-, coreutils
-, cudaPackages
-, fontconfig
-, freetype
-, gcc
-, glib
-, libuuid
-, libxml2
-, ncurses
-, opencv2
-, openssl
-, unixODBC
-, xorg
-# options
-, cudaSupport
-}:
-
-let
-  platform =
-    if stdenv.hostPlatform.system == "i686-linux" || stdenv.hostPlatform.system == "x86_64-linux" then
-      "Linux"
-    else
-      throw "Mathematica requires i686-linux or x86_64 linux";
-in
-stdenv.mkDerivation rec {
-  inherit meta src version;
-
-  pname = "mathematica";
-
-  buildInputs = [
-    coreutils
-    patchelf
-    alsa-lib
-    coreutils
-    fontconfig
-    freetype
-    gcc.cc
-    gcc.libc
-    glib
-    ncurses
-    opencv2
-    openssl
-    unixODBC
-    libxml2
-    libuuid
-  ] ++ (with xorg; [
-    libX11
-    libXext
-    libXtst
-    libXi
-    libXmu
-    libXrender
-    libxcb
-    libXcursor
-    libXfixes
-    libXrandr
-    libICE
-    libSM
-  ]);
-
-  ldpath = lib.makeLibraryPath buildInputs
-    + lib.optionalString (stdenv.hostPlatform.system == "x86_64-linux")
-      (":" + lib.makeSearchPathOutput "lib" "lib64" buildInputs);
-
-  dontConfigure = true;
-  dontBuild = true;
-
-  unpackPhase = ''
-    echo "=== Extracting makeself archive ==="
-    # find offset from file
-    offset=$(${stdenv.shell} -c "$(grep -axm1 -e 'offset=.*' $src); echo \$offset" $src)
-    dd if="$src" ibs=$offset skip=1 | tar -xf -
-    cd Unix
-  '';
-
-  installPhase = ''
-    cd Installer
-    # don't restrict PATH, that has already been done
-    sed -i -e 's/^PATH=/# PATH=/' MathInstaller
-
-    echo "=== Running MathInstaller ==="
-    ./MathInstaller -auto -createdir=y -execdir=$out/bin -targetdir=$out/libexec/Mathematica -platforms=${platform} -silent
-  '';
-
-  preFixup = ''
-    echo "=== PatchElfing away ==="
-    # This code should be a bit forgiving of errors, unfortunately
-    set +e
-    find $out/libexec/Mathematica/SystemFiles -type f -perm -0100 | while read f; do
-      type=$(readelf -h "$f" 2>/dev/null | grep 'Type:' | sed -e 's/ *Type: *\([A-Z]*\) (.*/\1/')
-      if [ -z "$type" ]; then
-        :
-      elif [ "$type" == "EXEC" ]; then
-        echo "patching $f executable <<"
-        patchelf --shrink-rpath "$f"
-        patchelf \
-    --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
-          --set-rpath "$(patchelf --print-rpath "$f"):${ldpath}" \
-          "$f" \
-          && patchelf --shrink-rpath "$f" \
-          || echo unable to patch ... ignoring 1>&2
-      elif [ "$type" == "DYN" ]; then
-        echo "patching $f library <<"
-        patchelf \
-          --set-rpath "$(patchelf --print-rpath "$f"):${ldpath}" \
-          "$f" \
-          && patchelf --shrink-rpath "$f" \
-          || echo unable to patch ... ignoring 1>&2
-      else
-        echo "not patching $f <<: unknown elf type"
-      fi
-    done
-  '';
-
-  # all binaries are already stripped
-  dontStrip = true;
-
-  # we did this in prefixup already
-  dontPatchELF = true;
-}
diff --git a/pkgs/applications/science/math/mathematica/11.nix b/pkgs/applications/science/math/mathematica/11.nix
deleted file mode 100644
index 5b9460f76e06d..0000000000000
--- a/pkgs/applications/science/math/mathematica/11.nix
+++ /dev/null
@@ -1,146 +0,0 @@
-{ lib
-, patchelf
-, requireFile
-, stdenv
-# arguments from default.nix
-, lang
-, meta
-, name
-, src
-, version
-# dependencies
-, alsa-lib
-, coreutils
-, cudaPackages
-, dbus
-, fontconfig
-, freetype
-, gcc
-, glib
-, libGL
-, libGLU
-, libuuid
-, libxml2
-, ncurses
-, opencv2
-, openssl
-, unixODBC
-, xkeyboard_config
-, xorg
-, zlib
-# options
-, cudaSupport
-}:
-
-stdenv.mkDerivation rec {
-  inherit meta name src version;
-
-  buildInputs = [
-    coreutils
-    patchelf
-    alsa-lib
-    coreutils
-    dbus
-    fontconfig
-    freetype
-    gcc.cc
-    gcc.libc
-    glib
-    ncurses
-    opencv2
-    openssl
-    unixODBC
-    xkeyboard_config
-    libxml2
-    libuuid
-    zlib
-    libGL
-    libGLU
-  ] ++ (with xorg; [
-    libX11
-    libXext
-    libXtst
-    libXi
-    libXmu
-    libXrender
-    libxcb
-    libXcursor
-    libXfixes
-    libXrandr
-    libICE
-    libSM
-  ]);
-
-  ldpath = lib.makeLibraryPath buildInputs
-    + lib.optionalString (stdenv.hostPlatform.system == "x86_64-linux")
-      (":" + lib.makeSearchPathOutput "lib" "lib64" buildInputs);
-
-  dontConfigure = true;
-  dontBuild = true;
-
-  unpackPhase = ''
-    echo "=== Extracting makeself archive ==="
-    # find offset from file
-    offset=$(${stdenv.shell} -c "$(grep -axm1 -e 'offset=.*' $src); echo \$offset" $src)
-    dd if="$src" ibs=$offset skip=1 | tar -xf -
-    cd Unix
-  '';
-
-  installPhase = ''
-    cd Installer
-    # don't restrict PATH, that has already been done
-    sed -i -e 's/^PATH=/# PATH=/' MathInstaller
-    sed -i -e 's/\/bin\/bash/\/bin\/sh/' MathInstaller
-
-    echo "=== Running MathInstaller ==="
-    ./MathInstaller -auto -createdir=y -execdir=$out/bin -targetdir=$out/libexec/Mathematica -silent
-
-    # Fix library paths
-    cd $out/libexec/Mathematica/Executables
-    for path in mathematica MathKernel Mathematica WolframKernel wolfram math; do
-      sed -i -e 's#export LD_LIBRARY_PATH$#export LD_LIBRARY_PATH=${zlib}/lib:\''${LD_LIBRARY_PATH}#' $path
-    done
-
-    # Fix xkeyboard config path for Qt
-    for path in mathematica Mathematica; do
-      line=$(grep -n QT_PLUGIN_PATH $path | sed 's/:.*//')
-      sed -i -e "$line iexport QT_XKB_CONFIG_ROOT=\"${xkeyboard_config}/share/X11/xkb\"" $path
-    done
-  '';
-
-  preFixup = ''
-    echo "=== PatchElfing away ==="
-    # This code should be a bit forgiving of errors, unfortunately
-    set +e
-    find $out/libexec/Mathematica/SystemFiles -type f -perm -0100 | while read f; do
-      type=$(readelf -h "$f" 2>/dev/null | grep 'Type:' | sed -e 's/ *Type: *\([A-Z]*\) (.*/\1/')
-      if [ -z "$type" ]; then
-        :
-      elif [ "$type" == "EXEC" ]; then
-        echo "patching $f executable <<"
-        patchelf --shrink-rpath "$f"
-        patchelf \
-    --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
-          --set-rpath "$(patchelf --print-rpath "$f"):${ldpath}" \
-          "$f" \
-          && patchelf --shrink-rpath "$f" \
-          || echo unable to patch ... ignoring 1>&2
-      elif [ "$type" == "DYN" ]; then
-        echo "patching $f library <<"
-        patchelf \
-          --set-rpath "$(patchelf --print-rpath "$f"):${ldpath}" \
-          "$f" \
-          && patchelf --shrink-rpath "$f" \
-          || echo unable to patch ... ignoring 1>&2
-      else
-        echo "not patching $f <<: unknown elf type"
-      fi
-    done
-  '';
-
-  # all binaries are already stripped
-  dontStrip = true;
-
-  # we did this in prefixup already
-  dontPatchELF = true;
-}
diff --git a/pkgs/applications/science/math/mathematica/9.nix b/pkgs/applications/science/math/mathematica/9.nix
deleted file mode 100644
index c2fc07c532fc9..0000000000000
--- a/pkgs/applications/science/math/mathematica/9.nix
+++ /dev/null
@@ -1,118 +0,0 @@
-{ lib
-, patchelf
-, requireFile
-, stdenv
-# arguments from default.nix
-, lang
-, meta
-, name
-, src
-, version
-# dependencies
-, alsa-lib
-, coreutils
-, cudaPackages
-, fontconfig
-, freetype
-, gcc
-, glib
-, ncurses
-, opencv2
-, openssl
-, unixODBC
-, xorg
-# options
-, cudaSupport
-}:
-
-let
-  platform =
-    if stdenv.hostPlatform.system == "i686-linux" || stdenv.hostPlatform.system == "x86_64-linux" then
-      "Linux"
-    else
-      throw "Mathematica requires i686-linux or x86_64 linux";
-in
-stdenv.mkDerivation rec {
-  inherit meta src version;
-  pname = "mathematica";
-
-  buildInputs = [
-    coreutils
-    patchelf
-    alsa-lib
-    coreutils
-    fontconfig
-    freetype
-    gcc.cc
-    gcc.libc
-    glib
-    ncurses
-    opencv2
-    openssl
-    unixODBC
-  ] ++ (with xorg; [
-    libX11
-    libXext
-    libXtst
-    libXi
-    libXmu
-    libXrender
-    libxcb
-  ]);
-
-  ldpath = lib.makeLibraryPath buildInputs
-    + lib.optionalString (stdenv.hostPlatform.system == "x86_64-linux")
-    (":" + lib.makeSearchPathOutput "lib" "lib64" buildInputs);
-
-  dontConfigure = true;
-  dontBuild = true;
-
-  unpackPhase = ''
-    echo "=== Extracting makeself archive ==="
-    # find offset from file
-    offset=$(${stdenv.shell} -c "$(grep -axm1 -e 'offset=.*' $src); echo \$offset" $src)
-    dd if="$src" ibs=$offset skip=1 | tar -xf -
-    cd Unix
-  '';
-
-  installPhase = ''
-    cd Installer
-    # don't restrict PATH, that has already been done
-    sed -i -e 's/^PATH=/# PATH=/' MathInstaller
-
-    echo "=== Running MathInstaller ==="
-    ./MathInstaller -auto -createdir=y -execdir=$out/bin -targetdir=$out/libexec/Mathematica -platforms=${platform} -silent
-  '';
-
-  preFixup = ''
-    echo "=== PatchElfing away ==="
-    find $out/libexec/Mathematica/SystemFiles -type f -perm -0100 | while read f; do
-      type=$(readelf -h "$f" 2>/dev/null | grep 'Type:' | sed -e 's/ *Type: *\([A-Z]*\) (.*/\1/')
-      if [ -z "$type" ]; then
-        :
-      elif [ "$type" == "EXEC" ]; then
-        echo "patching $f executable <<"
-        patchelf \
-            --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
-            --set-rpath "${ldpath}" \
-            "$f"
-        patchelf --shrink-rpath "$f"
-      elif [ "$type" == "DYN" ]; then
-        echo "patching $f library <<"
-        patchelf \
-          --set-rpath "$(patchelf --print-rpath "$f"):${ldpath}" \
-          "$f" \
-          && patchelf --shrink-rpath "$f" \
-          || echo unable to patch ... ignoring 1>&2
-      else
-        echo "not patching $f <<: unknown elf type"
-      fi
-    done
-  '';
-
-  # all binaries are already stripped
-  dontStrip = true;
-
-  # we did this in prefixup already
-  dontPatchELF = true;
-}
diff --git a/pkgs/applications/science/math/mathematica/default.nix b/pkgs/applications/science/math/mathematica/default.nix
index c4cebcd8e29ad..9d0a308f44357 100644
--- a/pkgs/applications/science/math/mathematica/default.nix
+++ b/pkgs/applications/science/math/mathematica/default.nix
@@ -44,12 +44,6 @@ let versions = callPackage ./versions.nix { };
                         else "and with local documentation"}")
       else lib.head matching-versions;
 
-    specific-drv = ./. + "/${lib.versions.major found-version.version}.nix";
-
-    real-drv = if lib.pathExists specific-drv
-               then specific-drv
-               else ./generic.nix;
-
     isMatching = v1: v2:
       let as      = lib.splitVersion v1;
           bs      = lib.splitVersion v2;
@@ -59,12 +53,12 @@ let versions = callPackage ./versions.nix { };
 
     matchesDoc = v:
       builtins.match (if webdoc
-                      then ".*[0-9]_LINUX.sh"
-                      else ".*[0-9]_BNDL_LINUX.sh") v.src.name != null;
+                      then ".*[0-9]_LIN(UX)?.sh"
+                      else ".*_B[Nn][Dd][Ll].sh") v.src.name != null;
 
 in
 
-callPackage real-drv {
+callPackage ./generic.nix {
   inherit cudaSupport cudaPackages;
   inherit (found-version) version lang;
   src = if source == null then found-version.src else source;
@@ -77,7 +71,7 @@ callPackage real-drv {
     homepage = "http://www.wolfram.com/mathematica/";
     license = licenses.unfree;
     sourceProvenance = with sourceTypes; [ binaryNativeCode ];
-    maintainers = with maintainers; [ herberteuler rafaelrc ];
+    maintainers = with maintainers; [ herberteuler rafaelrc chewblacka ];
     platforms = [ "x86_64-linux" ];
   };
 }
diff --git a/pkgs/applications/science/math/mathematica/generic.nix b/pkgs/applications/science/math/mathematica/generic.nix
index 5a96bf1a26252..6bf8992308125 100644
--- a/pkgs/applications/science/math/mathematica/generic.nix
+++ b/pkgs/applications/science/math/mathematica/generic.nix
@@ -1,4 +1,4 @@
-{ addOpenGLRunpath
+{ addDriverRunpath
 , autoPatchelfHook
 , lib
 , makeWrapper
@@ -57,7 +57,7 @@ let cudaEnv = symlinkJoin {
       ];
       postBuild = ''
         if [ ! -e $out/lib/libcuda.so ]; then
-            ln -s ${addOpenGLRunpath.driverLink}/lib/libcuda.so $out/lib
+            ln -s ${addDriverRunpath.driverLink}/lib/libcuda.so $out/lib
         fi
         ln -s lib $out/lib64
       '';
@@ -69,7 +69,7 @@ in stdenv.mkDerivation {
   nativeBuildInputs = [
     autoPatchelfHook
     makeWrapper
-  ] ++ lib.optional cudaSupport addOpenGLRunpath;
+  ] ++ lib.optional cudaSupport addDriverRunpath;
 
   buildInputs = [
     alsa-lib
@@ -136,8 +136,8 @@ in stdenv.mkDerivation {
     "--set QT_QPA_PLATFORM wayland;xcb"
   ] ++ lib.optionals cudaSupport [
     "--set CUDA_PATH ${cudaEnv}"
-    "--set NVIDIA_DRIVER_LIBRARY_PATH ${addOpenGLRunpath.driverLink}/lib/libnvidia-tls.so"
-    "--set CUDA_LIBRARY_PATH ${addOpenGLRunpath.driverLink}/lib/libcuda.so"
+    "--set NVIDIA_DRIVER_LIBRARY_PATH ${addDriverRunpath.driverLink}/lib/libnvidia-tls.so"
+    "--set CUDA_LIBRARY_PATH ${addDriverRunpath.driverLink}/lib/libcuda.so"
   ];
 
   unpackPhase = ''
@@ -157,9 +157,15 @@ in stdenv.mkDerivation {
 
     mkdir -p "$out/lib/udev/rules.d"
 
-    # Patch MathInstaller's shebangs and udev rules dir
-    patchShebangs MathInstaller
-    substituteInPlace MathInstaller \
+    # Set name of installer file
+    if [ -f "MathInstaller" ]; then
+      INSTALLER="MathInstaller"
+    else
+      INSTALLER="WolframInstaller"
+    fi
+    # Patch Installer's shebangs and udev rules dir
+    patchShebangs $INSTALLER
+    substituteInPlace $INSTALLER \
       --replace /etc/udev/rules.d $out/lib/udev/rules.d
 
     # Remove PATH restriction, root and avahi daemon checks, and hostname call
@@ -169,13 +175,13 @@ in stdenv.mkDerivation {
       s/^\s*checkAvahiDaemon$/:/
       s/^\s*installBundledInstall$/:/
       s/`hostname`/""/
-    ' MathInstaller
+    ' $INSTALLER
 
     # NOTE: some files placed under HOME may be useful
     XDG_DATA_HOME="$out/share" HOME="$TMPDIR/home" vernierLink=y \
-      ./MathInstaller -execdir="$out/bin" -targetdir="$out/libexec/Mathematica" -auto -verbose -createdir=y
+      ./$INSTALLER -execdir="$out/bin" -targetdir="$out/libexec/Mathematica" -auto -verbose -createdir=y
 
-    # Check if MathInstaller produced any errors
+    # Check if Installer produced any errors
     errLog="$out/libexec/Mathematica/InstallErrors"
     if [ -f "$errLog" ]; then
       echo "Installation errors:"
diff --git a/pkgs/applications/science/math/mathematica/versions.nix b/pkgs/applications/science/math/mathematica/versions.nix
index 3bbf70433471f..a88aca6f12a8f 100644
--- a/pkgs/applications/science/math/mathematica/versions.nix
+++ b/pkgs/applications/science/math/mathematica/versions.nix
@@ -8,6 +8,20 @@
 
 let versions = [
   {
+    version = "14.1.0";
+    lang = "en";
+    language = "English";
+    sha256 = "sha256-PCpjwqA6NC+iwvYxddYBlmF5+vl76r+MoIYAL91WFns=";
+    installer = "Wolfram_14.1.0_LIN.sh";
+  }
+  {
+    version = "14.1.0";
+    lang = "en";
+    language = "English";
+    sha256 = "sha256-pnu60Pv3xo3+MAkDLiU3yTPVbbQ00diV45vSVL8B310=";
+    installer = "Wolfram_14.1.0_LIN_Bndl.sh";
+  }
+  {
     version = "14.0.0";
     lang = "en";
     language = "English";
@@ -147,34 +161,6 @@ let versions = [
     sha256 = "sha256-uftx4a/MHXLCABlv+kNFEtII+ikg4geHhDP1BOWK6dc=";
     installer = "Mathematica_12.0.0_LINUX.sh";
   }
-  {
-    version = "11.3.0";
-    lang = "en";
-    language = "English";
-    sha256 = "sha256-D8/iCMHqyESOe+OvC9uENwsXvZxdBmwBOSjI7pWu0Q4=";
-    installer = "Mathematica_11.3.0_LINUX.sh";
-  }
-  {
-    version = "11.2.0";
-    lang = "ja";
-    language = "Japanese";
-    sha256 = "sha256-kWOS7dMr7YYiI430Nd2OhkJrsEMDijM28w3xDYGbSbE=";
-    installer = "Mathematica_11.2.0_ja_LINUX.sh";
-  }
-  {
-    version = "9.0.0";
-    lang = "en";
-    language = "English";
-    sha256 = "sha256-mKgxdd7dLWa5EOuR5C37SeU+UC9Cv5YTbY5xSK9y34A=";
-    installer = "Mathematica_9.0.0_LINUX.sh";
-  }
-  {
-    version = "10.0.2";
-    lang = "en";
-    language = "English";
-    sha256 = "sha256-NHUg1jzLos1EsIr8TdYdNaA5+3jEcFqVZIr9GVVUXrQ=";
-    installer = "Mathematica_10.0.2_LINUX.sh";
-  }
 ];
 
 in
diff --git a/pkgs/applications/science/math/maxima/5.47.0-CVE-2024-34490.patch b/pkgs/applications/science/math/maxima/5.47.0-CVE-2024-34490.patch
new file mode 100644
index 0000000000000..008fe725fa895
--- /dev/null
+++ b/pkgs/applications/science/math/maxima/5.47.0-CVE-2024-34490.patch
@@ -0,0 +1,86 @@
+Based on upstream https://sourceforge.net/p/maxima/code/ci/51704ccb090f6f971b641e4e0b7c1c22c4828bf7/
+adjusted to apply to 5.47.0
+
+diff --git a/src/gnuplot_def.lisp b/src/gnuplot_def.lisp
+index 80c174bd5..6fdc8da6d 100644
+--- a/src/gnuplot_def.lisp
++++ b/src/gnuplot_def.lisp
+@@ -286,7 +286,7 @@
+                (format nil "set term postscript eps color solid lw 2 size 16.4 cm, 12.3 cm font \",24\" ~a" gstrings)))
+      (if (getf plot-options :gnuplot_out_file)
+          (setq out-file (getf plot-options :gnuplot_out_file))
+-         (setq out-file "maxplot.ps")))
++         (setq out-file (format nil "~a.ps" (random-name 16)))))
+     ((eq (getf plot-options :gnuplot_term) '$dumb)
+      (if (getf plot-options :gnuplot_dumb_term_command)
+          (setq terminal-command
+@@ -294,7 +294,7 @@
+          (setq terminal-command "set term dumb 79 22"))
+      (if (getf plot-options :gnuplot_out_file)
+          (setq out-file (getf plot-options :gnuplot_out_file))
+-         (setq out-file "maxplot.txt")))
++         (setq out-file (format nil "~a.txt" (random-name 16)))))
+     ((eq (getf plot-options :gnuplot_term) '$default)
+      (if (getf plot-options :gnuplot_default_term_command)
+          (setq terminal-command
+diff --git a/src/plot.lisp b/src/plot.lisp
+index fb2b3136b..8877f7025 100644
+--- a/src/plot.lisp
++++ b/src/plot.lisp
+@@ -1755,16 +1755,24 @@ plot3d([cos(y)*(10.0+6*cos(x)), sin(y)*(10.0+6*cos(x)),-6*sin(x)],
+ 
+ (defvar $xmaxima_plot_command "xmaxima")
+ 
++;; random-file-name
++;; Creates a random word of 'count' alphanumeric characters
++(defun random-name (count)
++  (let ((chars "0123456789abcdefghijklmnopqrstuvwxyz") (name ""))
++    (setf *random-state* (make-random-state t))
++    (dotimes (i count)
++      (setq name (format nil "~a~a" name (aref chars (random 36)))))
++    name))
++
+ (defun plot-set-gnuplot-script-file-name (options)
+   (let ((gnuplot-term (getf options :gnuplot_term))
+ 	(gnuplot-out-file (getf options :gnuplot_out_file)))
+     (if (and (find (getf options :plot_format) '($gnuplot_pipes $gnuplot))
+              (eq gnuplot-term '$default) gnuplot-out-file)
+ 	(plot-file-path gnuplot-out-file t options)
+-      (plot-file-path
+-       (format nil "maxout~d.~(~a~)"
+-	       (getpid)
+-               (ensure-string (getf options :plot_format))) nil options))))
++      (plot-file-path (format nil "~a.~a" (random-name 16)
++                              (ensure-string (getf options :plot_format)))
++                      nil options))))
+ 
+ (defun plot-temp-file0 (file &optional (preserve-file nil))
+   (let ((filename 
+@@ -2577,9 +2585,13 @@ plot2d ( x^2+y^2 = 1, [x, -2, 2], [y, -2 ,2]);
+        (format dest "}~%"))
+   (format dest "}~%"))
+ 
++; TODO: Check whether this function is still being used (villate 20240325)
+ (defun show-open-plot (ans file)
+   (cond ($show_openplot
+-         (with-open-file (st1 (plot-temp-file (format nil "maxout~d.xmaxima" (getpid))) :direction :output :if-exists :supersede)
++         (with-open-file
++          (st1 (plot-temp-file
++                (format nil "~a.xmaxima" (random-name 16)))
++               :direction :output :if-exists :supersede)
+            (princ  ans st1))
+          ($system (concatenate 'string *maxima-prefix* 
+                                (if (string= *autoconf-windows* "true") "\\bin\\" "/bin/") 
+diff --git a/src/xmaxima_def.lisp b/src/xmaxima_def.lisp
+index b6513b564..5a13b6141 100644
+--- a/src/xmaxima_def.lisp
++++ b/src/xmaxima_def.lisp
+@@ -431,7 +431,7 @@
+         (format $pstream "}~%"))))))
+ 
+ (defmethod plot-shipout ((plot xmaxima-plot) options &optional output-file)
+-  (let ((file (plot-file-path (format nil "maxout~d.xmaxima" (getpid)))))
++  (let ((file (plot-file-path (format nil "~a.xmaxima" (random-name 16)))))
+     (cond ($show_openplot
+            (with-open-file (fl
+                             #+sbcl (sb-ext:native-namestring file)
diff --git a/pkgs/applications/science/math/maxima/default.nix b/pkgs/applications/science/math/maxima/default.nix
index e7ac178cd5d13..c1458186b2ae1 100644
--- a/pkgs/applications/science/math/maxima/default.nix
+++ b/pkgs/applications/science/math/maxima/default.nix
@@ -20,11 +20,11 @@ let
 in
 stdenv.mkDerivation (finalAttrs: {
   pname = "maxima";
-  version = "5.46.0";
+  version = "5.47.0";
 
   src = fetchurl {
-    url = "mirror://sourceforge/${finalAttrs.pname}/${finalAttrs.pname}-${finalAttrs.version}.tar.gz";
-    sha256 = "sha256-c5Dwa0jaZckDPosvYpuXi5AFZFSlQCLbfecOIiWqiwc=";
+    url = "mirror://sourceforge/maxima/maxima-${finalAttrs.version}.tar.gz";
+    sha256 = "sha256-kQQCGyT9U+jAOpg1CctC6TepJejAyFwzXXcJoU/UD3o=";
   };
 
   nativeBuildInputs = [
@@ -79,6 +79,8 @@ stdenv.mkDerivation (finalAttrs: {
       url = "https://raw.githubusercontent.com/sagemath/sage/07d6c37d18811e2b377a9689790a7c5e24da16ba/build/pkgs/maxima/patches/undoing_true_false_printing_patch.patch";
       sha256 = "0fvi3rcjv6743sqsbgdzazy9jb6r1p1yq63zyj9fx42wd1hgf7yx";
     })
+
+    ./5.47.0-CVE-2024-34490.patch
   ];
 
   # The test suite is disabled since 5.42.2 because of the following issues:
diff --git a/pkgs/applications/science/math/msieve/default.nix b/pkgs/applications/science/math/msieve/default.nix
index bda3e5b3a040a..a5af9e844eca4 100644
--- a/pkgs/applications/science/math/msieve/default.nix
+++ b/pkgs/applications/science/math/msieve/default.nix
@@ -2,12 +2,12 @@
 
 stdenv.mkDerivation rec {
   pname = "msieve";
-  version = "r1050";
+  version = "1056";
 
   src = fetchsvn {
     url = "svn://svn.code.sf.net/p/msieve/code/trunk";
-    rev = "1050";
-    hash = "sha256-cn6OhE4zhrpB7BFrRdOnucjATbfo5mLkK7O0Usx1quE=";
+    rev = version;
+    hash = "sha256-6ErVn4pYPMG5VFjOQURLsHNpN0pGdp55+rjY8988onU=";
   };
 
   buildInputs = [ zlib gmp ecm ];
diff --git a/pkgs/applications/science/math/mxnet/default.nix b/pkgs/applications/science/math/mxnet/default.nix
index 839537438962b..880caaff5afb6 100644
--- a/pkgs/applications/science/math/mxnet/default.nix
+++ b/pkgs/applications/science/math/mxnet/default.nix
@@ -16,7 +16,7 @@ stdenv.mkDerivation rec {
 
   src = fetchurl {
     name = "apache-mxnet-src-${version}-incubating.tar.gz";
-    url = "https://dlcdn.apache.org/incubator/mxnet/${version}/apache-mxnet-src-${version}-incubating.tar.gz";
+    url = "mirror://apache/incubator/mxnet/${version}/apache-mxnet-src-${version}-incubating.tar.gz";
     hash = "sha256-EephMoF02MKblvNBl34D3rC/Sww3rOZY+T442euMkyI=";
   };
 
diff --git a/pkgs/applications/science/math/nota/default.nix b/pkgs/applications/science/math/nota/default.nix
index eae11806d7254..3a98eacd47171 100644
--- a/pkgs/applications/science/math/nota/default.nix
+++ b/pkgs/applications/science/math/nota/default.nix
@@ -36,6 +36,6 @@ mkDerivation rec {
   description = "Most beautiful command line calculator";
   homepage = "https://kary.us/nota";
   license = lib.licenses.mpl20;
-  maintainers = with lib.maintainers; [ dtzWill ];
+  maintainers = [ ];
   mainProgram = "nota";
 }
diff --git a/pkgs/applications/science/math/numworks-epsilon/default.nix b/pkgs/applications/science/math/numworks-epsilon/default.nix
index 98d5d0d4560ad..71da675614da9 100644
--- a/pkgs/applications/science/math/numworks-epsilon/default.nix
+++ b/pkgs/applications/science/math/numworks-epsilon/default.nix
@@ -14,13 +14,13 @@
 
 stdenv.mkDerivation rec {
   pname = "numworks-epsilon";
-  version = "22.2.0";
+  version = "23.2.3";
 
   src = fetchFromGitHub {
     owner = "numworks";
     repo = "epsilon";
     rev = version;
-    hash = "sha256-E2WaXTn8+Ky9kdZxvQmEt63Ggo6Ns0fZ0Za+rQGIMSg=";
+    hash = "sha256-w9ddcULE1MrGnYcXA0qOg1elQv/eBhcXqhMSjWT3Bkk=";
   };
 
   nativeBuildInputs = [ pkg-config ];
diff --git a/pkgs/applications/science/math/palp/default.nix b/pkgs/applications/science/math/palp/default.nix
index a3b54b78f99bc..0db35ba89ae61 100644
--- a/pkgs/applications/science/math/palp/default.nix
+++ b/pkgs/applications/science/math/palp/default.nix
@@ -21,7 +21,7 @@ stdenv.mkDerivation rec {
     "format"
   ];
 
-  patchPhase = lib.optionalString stdenv.isDarwin ''
+  patchPhase = lib.optionalString stdenv.hostPlatform.isDarwin ''
     substituteInPlace GNUmakefile --replace gcc cc
   '';
 
diff --git a/pkgs/applications/science/math/qalculate-gtk/default.nix b/pkgs/applications/science/math/qalculate-gtk/default.nix
index e4fc506516fdd..306d6141ac17a 100644
--- a/pkgs/applications/science/math/qalculate-gtk/default.nix
+++ b/pkgs/applications/science/math/qalculate-gtk/default.nix
@@ -2,19 +2,19 @@
 
 stdenv.mkDerivation (finalAttrs: {
   pname = "qalculate-gtk";
-  version = "5.1.0";
+  version = "5.2.0";
 
   src = fetchFromGitHub {
     owner = "qalculate";
     repo = "qalculate-gtk";
     rev = "v${finalAttrs.version}";
-    hash = "sha256-yI+8TrNZJt4eJnDX5mk6RozBe2ZeP7sTyAjsgiYQPck=";
+    hash = "sha256-vH4GZaeQ6Ji9aWh8R5B6PE2fBBW7KTyCsFkpgHu6yg8=";
   };
 
   hardeningDisable = [ "format" ];
 
   nativeBuildInputs = [ intltool pkg-config autoreconfHook wrapGAppsHook3 ]
-    ++ lib.optionals stdenv.isDarwin [ desktopToDarwinBundle ];
+    ++ lib.optionals stdenv.hostPlatform.isDarwin [ desktopToDarwinBundle ];
   buildInputs = [ libqalculate gtk3 curl ];
   enableParallelBuilding = true;
 
diff --git a/pkgs/applications/science/math/qalculate-qt/default.nix b/pkgs/applications/science/math/qalculate-qt/default.nix
index 3c4e19d56ebd7..2cde634498889 100644
--- a/pkgs/applications/science/math/qalculate-qt/default.nix
+++ b/pkgs/applications/science/math/qalculate-qt/default.nix
@@ -2,25 +2,25 @@
 
 stdenv.mkDerivation (finalAttrs: {
   pname = "qalculate-qt";
-  version = "5.1.0";
+  version = "5.2.0.1";
 
   src = fetchFromGitHub {
     owner = "qalculate";
     repo = "qalculate-qt";
     rev = "v${finalAttrs.version}";
-    hash = "sha256-gJfIC5HdA10gb/Dh/yhJbkCZfhUnN0zihqyfDjPv6ow=";
+    hash = "sha256-kzOxOCZmu4mYYgegRBU8SMAkTiE4p1AugVAeZa8yDDE=";
   };
 
   nativeBuildInputs = [ qmake intltool pkg-config qttools wrapQtAppsHook ];
   buildInputs = [ libqalculate qtbase qtsvg ]
-    ++ lib.optionals stdenv.isLinux [ qtwayland ];
+    ++ lib.optionals stdenv.hostPlatform.isLinux [ qtwayland ];
 
   postPatch = ''
     substituteInPlace qalculate-qt.pro\
       --replace "LRELEASE" "${qttools.dev}/bin/lrelease"
   '';
 
-  postInstall = lib.optionalString stdenv.isDarwin ''
+  postInstall = lib.optionalString stdenv.hostPlatform.isDarwin ''
     mkdir -p $out/Applications
     mv $out/bin/qalculate-qt.app $out/Applications
     makeWrapper $out/{Applications/qalculate-qt.app/Contents/MacOS,bin}/qalculate-qt
diff --git a/pkgs/applications/science/math/ratpoints/default.nix b/pkgs/applications/science/math/ratpoints/default.nix
index f2aa1aac26079..4aaed4a1b0edc 100644
--- a/pkgs/applications/science/math/ratpoints/default.nix
+++ b/pkgs/applications/science/math/ratpoints/default.nix
@@ -20,7 +20,7 @@ stdenv.mkDerivation rec {
   buildInputs = [ gmp ];
 
   makeFlags = [ "CC=${stdenv.cc.targetPrefix}cc" ];
-  buildFlags = lib.optionals stdenv.isDarwin ["CCFLAGS2=-lgmp -lc -lm" "CCFLAGS=-UUSE_SSE"];
+  buildFlags = lib.optionals stdenv.hostPlatform.isDarwin ["CCFLAGS2=-lgmp -lc -lm" "CCFLAGS=-UUSE_SSE"];
   installFlags = [ "INSTALL_DIR=$(out)" ];
 
   preInstall = ''mkdir -p "$out"/{bin,share,lib,include}'';
diff --git a/pkgs/applications/science/math/ripser/default.nix b/pkgs/applications/science/math/ripser/default.nix
index 3f536f25aa115..38a00d504406b 100644
--- a/pkgs/applications/science/math/ripser/default.nix
+++ b/pkgs/applications/science/math/ripser/default.nix
@@ -5,14 +5,11 @@
 , fileFormat ? "lowerTriangularCsv"
 }:
 
-with lib;
-
-assert assertOneOf "fileFormat" fileFormat
+assert lib.assertOneOf "fileFormat" fileFormat
   ["lowerTriangularCsv" "upperTriangularCsv" "dipha"];
 assert useGoogleHashmap -> sparsehash != null;
 
 let
-  inherit (lib) optional;
   version = "1.2.1";
 in
 stdenv.mkDerivation {
@@ -26,19 +23,19 @@ stdenv.mkDerivation {
     sha256 = "sha256-BxmkPQ/nl5cF+xwQMTjXnLgkLgdmT/39y7Kzl2wDfpE=";
   };
 
-  buildInputs = optional useGoogleHashmap sparsehash;
+  buildInputs = lib.optional useGoogleHashmap sparsehash;
 
   buildFlags = [
     "-std=c++11"
     "-O3"
     "-D NDEBUG"
   ]
-  ++ optional useCoefficients "-D USE_COEFFICIENTS"
-  ++ optional indicateProgress "-D INDICATE_PROGRESS"
-  ++ optional useGoogleHashmap "-D USE_GOOGLE_HASHMAP"
-  ++ optional (fileFormat == "lowerTriangularCsv") "-D FILE_FORMAT_LOWER_TRIANGULAR_CSV"
-  ++ optional (fileFormat == "upperTriangularCsv") "-D FILE_FORMAT_UPPER_TRIANGULAR_CSV"
-  ++ optional (fileFormat == "dipha") "-D FILE_FORMAT_DIPHA"
+  ++ lib.optional useCoefficients "-D USE_COEFFICIENTS"
+  ++ lib.optional indicateProgress "-D INDICATE_PROGRESS"
+  ++ lib.optional useGoogleHashmap "-D USE_GOOGLE_HASHMAP"
+  ++ lib.optional (fileFormat == "lowerTriangularCsv") "-D FILE_FORMAT_LOWER_TRIANGULAR_CSV"
+  ++ lib.optional (fileFormat == "upperTriangularCsv") "-D FILE_FORMAT_UPPER_TRIANGULAR_CSV"
+  ++ lib.optional (fileFormat == "dipha") "-D FILE_FORMAT_DIPHA"
   ;
 
   buildPhase = "c++ ripser.cpp -o ripser $buildFlags";
diff --git a/pkgs/applications/science/math/sage/README.md b/pkgs/applications/science/math/sage/README.md
index 35e8d0deeffba..94a9b0b6bc29b 100644
--- a/pkgs/applications/science/math/sage/README.md
+++ b/pkgs/applications/science/math/sage/README.md
@@ -12,7 +12,7 @@ If the build broke as a result of a package update, try those solutions in order
 
 - search the [sage GitHub repo](https://github.com/sagemath/sage) for keywords like "Upgrade <package>". Maybe somebody has already proposed a patch that fixes the issue. You can then add a `fetchpatch` to `sage-src.nix`.
 
-- check if [gentoo](https://github.com/cschwan/sage-on-gentoo/tree/master/sci-mathematics/sage), [debian](https://salsa.debian.org/science-team/sagemath/tree/master/debian) or [arch linux](https://git.archlinux.org/svntogit/community.git/tree/trunk?h=packages/sagemath) already solved the problem. You can then again add a `fetchpatch` to `sage-src.nix`. If applicable you should also [propose the patch upstream](#proposing-a-sage-patch).
+- check if [gentoo](https://github.com/cschwan/sage-on-gentoo/tree/master/sci-mathematics/sage), [debian](https://salsa.debian.org/science-team/sagemath/tree/master/debian) or [arch linux](https://git.archlinux.org/svntogit/community.git/tree/trunk?h=packages/sagemath) already solved the problem. You can then again add a `fetchpatch` to `sage-src.nix`. If applicable you should also propose the patch upstream.
 
 - fix the problem yourself. First clone the sagemath source and then check out the sage version you want to patch:
 
diff --git a/pkgs/applications/science/math/sage/default.nix b/pkgs/applications/science/math/sage/default.nix
index 6624dcc36528b..95ad7ab120134 100644
--- a/pkgs/applications/science/math/sage/default.nix
+++ b/pkgs/applications/science/math/sage/default.nix
@@ -18,7 +18,7 @@ let
         inherit flint3;
         inherit sage-src env-locations singular;
         inherit (maxima) lisp-compiler;
-        linbox = pkgs.linbox.override { withSage = true; };
+        linbox = pkgs.linbox;
         pkg-config = pkgs.pkg-config; # not to confuse with pythonPackages.pkg-config
       };
 
@@ -97,6 +97,7 @@ let
   # Running the tests should take something in the order of 1h.
   sage-tests = callPackage ./sage-tests.nix {
     inherit sage-with-env;
+    pytest = python3.pkgs.pytest;
   };
 
   sage-src = callPackage ./sage-src.nix {};
diff --git a/pkgs/applications/science/math/sage/dist-tests.nix b/pkgs/applications/science/math/sage/dist-tests.nix
index 24a86a8f37a4b..45376b832b9f5 100644
--- a/pkgs/applications/science/math/sage/dist-tests.nix
+++ b/pkgs/applications/science/math/sage/dist-tests.nix
@@ -7,10 +7,10 @@
 # subset of files responsible for the vast majority of packaging tests, we can
 # think about moving this upstream.
 [
-	"src/sage/env.py" # [1]
-	"src/sage/misc/persist.pyx" # [1]
-	"src/sage/misc/inline_fortran.py" # [1]
-	"src/sage/repl/ipython_extension.py" # [1]
+  "src/sage/env.py" # [1]
+  "src/sage/misc/persist.pyx" # [1]
+  "src/sage/misc/inline_fortran.py" # [1]
+  "src/sage/repl/ipython_extension.py" # [1]
 ]
 
 # Numbered list of past failures to annotate files with
diff --git a/pkgs/applications/science/math/sage/patches/disable-singular-doctest.patch b/pkgs/applications/science/math/sage/patches/disable-singular-doctest.patch
new file mode 100644
index 0000000000000..8501d55e54882
--- /dev/null
+++ b/pkgs/applications/science/math/sage/patches/disable-singular-doctest.patch
@@ -0,0 +1,36 @@
+From d6362714c9acf4cab69f3e2e772ec0bb1dfd39fe Mon Sep 17 00:00:00 2001
+From: George Huebner <george@feyor.sh>
+Date: Mon, 22 Jul 2024 00:37:53 -0500
+Subject: [PATCH] disable singular version doctest to avoid exceeding the stack
+ limit
+
+It works fine interactively, only an issue for Nix builds
+---
+ src/sage/interfaces/singular.py | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/src/sage/interfaces/singular.py b/src/sage/interfaces/singular.py
+index c0ab80e0a6..c778acdb0c 100644
+--- a/src/sage/interfaces/singular.py
++++ b/src/sage/interfaces/singular.py
+@@ -1262,7 +1262,7 @@ class Singular(ExtraTabCompletion, Expect):
+ 
+         EXAMPLES::
+ 
+-            sage: singular.version()
++            sage: singular.version() # not tested
+             "Singular ... version 4...
+         """
+         return singular_version()
+@@ -2475,7 +2475,7 @@ def singular_version():
+ 
+     EXAMPLES::
+ 
+-        sage: singular.version()
++        sage: singular.version() # not tested
+         "Singular ... version 4...
+     """
+     return singular.eval('system("--version");')
+-- 
+2.44.1
+
diff --git a/pkgs/applications/science/math/sage/patches/gap-element-crash.patch b/pkgs/applications/science/math/sage/patches/gap-element-crash.patch
new file mode 100644
index 0000000000000..b5396e2b78543
--- /dev/null
+++ b/pkgs/applications/science/math/sage/patches/gap-element-crash.patch
@@ -0,0 +1,18 @@
+diff --git a/src/sage/libs/gap/element.pyx b/src/sage/libs/gap/element.pyx
+index b2b0681c052..b2e5807392c 100644
+--- a/src/sage/libs/gap/element.pyx
++++ b/src/sage/libs/gap/element.pyx
+@@ -35,6 +35,13 @@ from sage.structure.coerce cimport coercion_model as cm
+ ### helper functions to construct lists and records ########################
+ ############################################################################
+ 
++
++cdef extern from *:
++    """
++    #pragma GCC optimize("O1")
++    """
++
++
+ cdef Obj make_gap_list(sage_list) except NULL:
+     """
+     Convert Sage lists into Gap lists
diff --git a/pkgs/applications/science/math/sage/patches/silence-linker.patch b/pkgs/applications/science/math/sage/patches/silence-linker.patch
new file mode 100644
index 0000000000000..f11f6cc6d0e33
--- /dev/null
+++ b/pkgs/applications/science/math/sage/patches/silence-linker.patch
@@ -0,0 +1,27 @@
+From 06d3bb5d8ef007bbcd71ee157fd97cd69557383b Mon Sep 17 00:00:00 2001
+From: George Huebner <george@feyor.sh>
+Date: Sat, 20 Jul 2024 18:46:04 -0500
+Subject: [PATCH] sage.cython: silence linker
+
+(Nix+LLVM specific issue) "ld: warning: directory not found" causes
+any cython doctest to fail and is annoying, so I told ld to shut up.
+---
+ src/sage/misc/cython.py | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/src/sage/misc/cython.py b/src/sage/misc/cython.py
+index 545e1227b0..c5f4b69221 100644
+--- a/src/sage/misc/cython.py
++++ b/src/sage/misc/cython.py
+@@ -339,7 +339,7 @@ def cython(filename, verbose=0, compile_message=False,
+     Cython.Compiler.Options.pre_import = "sage.all" if sage_namespace else None
+ 
+     extra_compile_args = ['-w']  # no warnings
+-    extra_link_args = []
++    extra_link_args = ['-w']
+ 
+     ext = Extension(name,
+                     sources=[pyxfile],
+-- 
+2.44.1
+
diff --git a/pkgs/applications/science/math/sage/patches/sphinx-docbuild-subprocesses.patch b/pkgs/applications/science/math/sage/patches/sphinx-docbuild-subprocesses.patch
index 2bfac780dfca3..fecf2088e5045 100644
--- a/pkgs/applications/science/math/sage/patches/sphinx-docbuild-subprocesses.patch
+++ b/pkgs/applications/science/math/sage/patches/sphinx-docbuild-subprocesses.patch
@@ -1,15 +1,15 @@
 diff --git a/src/sage_docbuild/builders.py b/src/sage_docbuild/builders.py
-index c5be38600a..e1d15f62d3 100644
+index 871cc4705a2..4b718136b91 100644
 --- a/src/sage_docbuild/builders.py
 +++ b/src/sage_docbuild/builders.py
-@@ -105,31 +105,6 @@ def builder_helper(type):
+@@ -106,31 +106,6 @@ def builder_helper(type):
      """
      Return a function which builds the documentation for
      output type ``type``.
 -
 -    TESTS:
 -
--    Check that :trac:`25161` has been resolved::
+-    Check that :issue:`25161` has been resolved::
 -
 -        sage: from sage_docbuild.builders import DocBuilder
 -        sage: from sage_docbuild.__main__ import setup_parser
@@ -48,10 +48,10 @@ index c5be38600a..e1d15f62d3 100644
              if build_options.ABORT_ON_ERROR:
                  raise
 diff --git a/src/sage_docbuild/sphinxbuild.py b/src/sage_docbuild/sphinxbuild.py
-index 07c584de55..b83283a9ee 100644
+index 5621fe9e456..b1b91ce7b2c 100644
 --- a/src/sage_docbuild/sphinxbuild.py
 +++ b/src/sage_docbuild/sphinxbuild.py
-@@ -331,3 +331,8 @@ def runsphinx():
+@@ -323,3 +323,8 @@ def runsphinx():
          sys.stderr = saved_stderr
          sys.stdout.flush()
          sys.stderr.flush()
diff --git a/pkgs/applications/science/math/sage/python-modules/sage-docbuild.nix b/pkgs/applications/science/math/sage/python-modules/sage-docbuild.nix
index b45998bbcb86d..43f67b97a278e 100644
--- a/pkgs/applications/science/math/sage/python-modules/sage-docbuild.nix
+++ b/pkgs/applications/science/math/sage/python-modules/sage-docbuild.nix
@@ -1,6 +1,7 @@
 { lib
 , buildPythonPackage
 , sage-src
+, furo
 , jupyter-sphinx
 , sphinx
 , sphinx-copybutton
@@ -13,6 +14,7 @@ buildPythonPackage rec {
   src = sage-src;
 
   propagatedBuildInputs = [
+    furo
     jupyter-sphinx
     sphinx
     sphinx-copybutton
diff --git a/pkgs/applications/science/math/sage/sage-env.nix b/pkgs/applications/science/math/sage/sage-env.nix
index f95e08c51ff4d..1503d3a89957a 100644
--- a/pkgs/applications/science/math/sage/sage-env.nix
+++ b/pkgs/applications/science/math/sage/sage-env.nix
@@ -5,10 +5,12 @@
 , sage-docbuild
 , env-locations
 , gfortran
+, ninja
 , bash
 , coreutils
 , gnused
 , gnugrep
+, gawk
 , binutils
 , pythonEnv
 , python3
@@ -63,11 +65,13 @@ let
     "@sage-local@/build"
     pythonEnv
     gfortran # for inline fortran
+    ninja # for inline fortran via numpy.f2py
     stdenv.cc # for cython
     bash
     coreutils
     gnused
     gnugrep
+    gawk
     binutils.bintools
     pkg-config
     pari
@@ -184,7 +188,7 @@ writeTextFile rec {
     export SAGE_EXTCODE='${sagelib.src}/src/sage/ext_data'
 
   # for find_library
-    export DYLD_LIBRARY_PATH="${lib.makeLibraryPath [stdenv.cc.libc singular giac]}''${DYLD_LIBRARY_PATH:+:}$DYLD_LIBRARY_PATH"
+    export DYLD_LIBRARY_PATH="${lib.makeLibraryPath [stdenv.cc.libc singular giac gap]}''${DYLD_LIBRARY_PATH:+:}$DYLD_LIBRARY_PATH"
   '';
 } // { # equivalent of `passthru`, which `writeTextFile` doesn't support
   lib = sagelib;
diff --git a/pkgs/applications/science/math/sage/sage-src.nix b/pkgs/applications/science/math/sage/sage-src.nix
index de0c2e3b1e20e..b8d9e3e903a6d 100644
--- a/pkgs/applications/science/math/sage/sage-src.nix
+++ b/pkgs/applications/science/math/sage/sage-src.nix
@@ -1,4 +1,5 @@
 { stdenv
+, lib
 , fetchFromGitHub
 , fetchpatch
 , fetchurl
@@ -10,14 +11,14 @@
 # all get the same sources with the same patches applied.
 
 stdenv.mkDerivation rec {
-  version = "10.3";
+  version = "10.4";
   pname = "sage-src";
 
   src = fetchFromGitHub {
     owner = "sagemath";
     repo = "sage";
     rev = version;
-    hash = "sha256-OHtMv8t0RrP6R8XIREU+C1vpazeQLWa75wx9Mv6BN1U=";
+    hash = "sha256-BDO00ZSm5lnjEuA56VsY/FZyAhoG1hkFxdIlTtBZVBA=";
   };
 
   # contains essential files (e.g., setup.cfg) generated by the bootstrap script.
@@ -25,8 +26,8 @@ stdenv.mkDerivation rec {
   configure-src = fetchurl {
     # the hash below is the tagged commit's _parent_. it can also be found by looking for
     # the "configure" asset at https://github.com/sagemath/sage/releases/tag/${version}
-    url = "mirror://sageupstream/configure/configure-ab1a517b64b02bf15bbcb8d7c2d4d643bd5eff9b.tar.gz";
-    hash = "sha256-pe9AxTM+gFSR4/eVfUzay+4bwjoubbYeDPc+avKjlaw=";
+    url = "mirror://sageupstream/configure/configure-3c279ec5712e0fa35c5733e03e010970727d7189.tar.gz";
+    hash = "sha256-3bRlgIUSIq9tDzvI+ZfEd5LMy1qHXdItEwu1say4cx4=";
   };
 
   # Patches needed because of particularities of nix or the way this is packaged.
@@ -40,6 +41,13 @@ stdenv.mkDerivation rec {
     # we can now set the cache dir to be within the .sage directory. This is
     # not strictly necessary, but keeps us from littering in the user's HOME.
     ./patches/sympow-cache.patch
+  ] ++ lib.optionals (stdenv.cc.isClang) [
+    # https://github.com/NixOS/nixpkgs/pull/264126
+    # Dead links in python sysconfig cause LLVM linker warnings, leading to cython doctest failures.
+    ./patches/silence-linker.patch
+
+    # Stack overflows during doctests; this does not change functionality.
+    ./patches/disable-singular-doctest.patch
   ];
 
   # Since sage unfortunately does not release bugfix releases, packagers must
@@ -54,26 +62,9 @@ stdenv.mkDerivation rec {
     # https://github.com/sagemath/sage/issues/34575
     ./patches/disable-slow-glpk-test.patch
 
-    # https://github.com/sagemath/sage/pull/37489, landed in 10.4.beta1
-    (fetchpatch {
-      name = "quaternionalgebra-random-failure.patch";
-      url = "https://github.com/sagemath/sage/commit/1c3f991b9d3c5778e409e5414c6cfcd456113f19.diff";
-      hash = "sha256-uCXchYx26DdxTjR1k2748KCEHPnekKS2fAM7SpyhNvM=";
-    })
-
-    # https://github.com/sagemath/sage/pull/37763, landed in 10.4.beta2
-    (fetchpatch {
-      name = "scipy-fault-tolerance.patch";
-      url = "https://github.com/sagemath/sage/commit/551139c09f26a5da96b1187c3f0dd17b8d80ef84.diff";
-      hash = "sha256-PR4przrZ3ieHaW2nSY7l7VhNfrUupu9yCIrXpeyoAgg=";
-    })
-
-    # first two commits from https://github.com/sagemath/sage/pull/38100
-    (fetchpatch {
-      name = "sphinx-7.3-update.patch";
-      url = "https://github.com/sagemath/sage/compare/10.4.beta7...d2932e142991b442a3eee5dc4f8949e3f7e6fe5c.patch";
-      hash = "sha256-g6w0ImE0d2ocKnbGMQikcz9eI9r3/gESlA1NrQfGimk=";
-    })
+    # compile libs/gap/element.pyx with -O1
+    # a more conservative version of https://github.com/sagemath/sage/pull/37951
+    ./patches/gap-element-crash.patch
   ];
 
   # Patches needed because of package updates. We could just pin the versions of
@@ -83,11 +74,11 @@ stdenv.mkDerivation rec {
   # should come from or be proposed to upstream. This list will probably never
   # be empty since dependencies update all the time.
   packageUpgradePatches = [
-    # https://github.com/sagemath/sage/pull/37492
+    # https://github.com/sagemath/sage/pull/38500, positively reviewed, to land in 10.5.beta3
     (fetchpatch {
-      name = "singular-4.3.2p14-upgrade.patch";
-      url = "https://github.com/sagemath/sage/commit/a0c56816b051e97da44ac0a4e4d4f6915cf7fa0f.diff";
-      sha256 = "sha256-WGMmPeBoj2LUC+2qxWuaJL89QUuGt6axGvxWkpM9LYg=";
+      name = "cython-3.0.11-upgrade.patch";
+      url = "https://patch-diff.githubusercontent.com/raw/sagemath/sage/pull/38500.diff";
+      hash = "sha256-ePfH3Gy1T0UfpoVd3EZowCfy88CbE+yE2MV2itWthsA=";
     })
   ];
 
@@ -112,7 +103,7 @@ stdenv.mkDerivation rec {
 
   installPhase = ''
     cp -r . "$out"
-    tar xkzf ${configure-src} -C "$out"
+    tar xzf ${configure-src} -C "$out"
     rm "$out/configure"
   '';
 }
diff --git a/pkgs/applications/science/math/sage/sage-tests.nix b/pkgs/applications/science/math/sage/sage-tests.nix
index 1a415ae65e96a..e50754986709c 100644
--- a/pkgs/applications/science/math/sage/sage-tests.nix
+++ b/pkgs/applications/science/math/sage/sage-tests.nix
@@ -1,5 +1,6 @@
 { stdenv
 , lib
+, pytest
 , sage-with-env
 , makeWrapper
 , files ? null # "null" means run all tests
@@ -30,6 +31,7 @@ stdenv.mkDerivation {
 
   nativeBuildInputs = [ makeWrapper ];
   buildInputs = [
+    pytest
     sage-with-env
   ];
 
diff --git a/pkgs/applications/science/math/sage/sage.nix b/pkgs/applications/science/math/sage/sage.nix
index 81b55e841d244..cc39624b7f110 100644
--- a/pkgs/applications/science/math/sage/sage.nix
+++ b/pkgs/applications/science/math/sage/sage.nix
@@ -60,6 +60,6 @@ stdenv.mkDerivation rec {
     homepage = "https://www.sagemath.org";
     license = licenses.gpl2Plus;
     maintainers = teams.sage.members;
-    platforms = platforms.linux;
+    platforms = platforms.linux ++ [ "aarch64-darwin" ];
   };
 }
diff --git a/pkgs/applications/science/math/sage/sagelib.nix b/pkgs/applications/science/math/sage/sagelib.nix
index 1552de773d014..1a138eea81d9e 100644
--- a/pkgs/applications/science/math/sage/sagelib.nix
+++ b/pkgs/applications/science/math/sage/sagelib.nix
@@ -6,7 +6,7 @@
 , perl
 , pkg-config
 , sage-setup
-, pythonRelaxDepsHook
+, setuptools
 , gd
 , iml
 , libpng
@@ -63,6 +63,7 @@
 , lrcalc-python
 , matplotlib
 , memory-allocator
+, meson-python
 , mpmath
 , networkx
 , numpy
@@ -79,7 +80,6 @@
 , sphinx
 , sympy
 , typing-extensions
-, nbclassic
 }:
 
 assert (!blas.isILP64) && (!lapack.isILP64);
@@ -103,7 +103,7 @@ buildPythonPackage rec {
     pip # needed to query installed packages
     pkg-config
     sage-setup
-    pythonRelaxDepsHook
+    setuptools
   ];
 
   pythonRelaxDeps = [
@@ -173,6 +173,7 @@ buildPythonPackage rec {
     lrcalc-python
     matplotlib
     memory-allocator
+    meson-python
     mpmath
     networkx
     numpy
@@ -189,8 +190,6 @@ buildPythonPackage rec {
     sphinx
     sympy
     typing-extensions
-
-    nbclassic
   ];
 
   preBuild = ''
diff --git a/pkgs/applications/science/math/scalp/default.nix b/pkgs/applications/science/math/scalp/default.nix
index fc230a11966fb..a4d3dc52e0a96 100644
--- a/pkgs/applications/science/math/scalp/default.nix
+++ b/pkgs/applications/science/math/scalp/default.nix
@@ -18,7 +18,7 @@ stdenv.mkDerivation rec {
     url = "https://digidev.digi.e-technik.uni-kassel.de/git/scalp.git";
     # mirrored at https://git.sr.ht/~weijia/scalp
     rev = "185b84e4ff967f42cf2de5db4db4e6fa0cc18fb8";
-    sha256 = "sha256-NyMZdJwdD3FR6uweYCclJjfcf3Y24Bns1ViwsmJ5izg=";
+    hash = "sha256-NyMZdJwdD3FR6uweYCclJjfcf3Y24Bns1ViwsmJ5izg=";
   };
 
   nativeBuildInputs = [
@@ -33,7 +33,7 @@ stdenv.mkDerivation rec {
     lp_solve
   ];
 
-  postPatch = lib.optionalString stdenv.isDarwin ''
+  postPatch = lib.optionalString stdenv.hostPlatform.isDarwin ''
     substituteInPlace CMakeLists.txt \
       --replace "\''$ORIGIN" "\''${CMAKE_INSTALL_PREFIX}/lib"
   '';
diff --git a/pkgs/applications/science/math/scilab-bin/default.nix b/pkgs/applications/science/math/scilab-bin/default.nix
index f6da20531385b..e3ca7bef52a4b 100644
--- a/pkgs/applications/science/math/scilab-bin/default.nix
+++ b/pkgs/applications/science/math/scilab-bin/default.nix
@@ -100,4 +100,4 @@ let
     '';
   };
 in
-if stdenv.isDarwin then darwin else linux
+if stdenv.hostPlatform.isDarwin then darwin else linux
diff --git a/pkgs/applications/science/math/singular/default.nix b/pkgs/applications/science/math/singular/default.nix
index d1b17eccee23b..fff9c7dfaf903 100644
--- a/pkgs/applications/science/math/singular/default.nix
+++ b/pkgs/applications/science/math/singular/default.nix
@@ -7,6 +7,7 @@
 , getconf
 , flint3
 , ntl
+, mpfr
 , cddlib
 , gfan
 , lrcalc
@@ -15,8 +16,7 @@
 , latex2html
 , texinfo
 , texliveSmall
-, enableDocs ? !stdenv.isDarwin
-, enableGfanlib ? true
+, enableDocs ? true
 }:
 
 stdenv.mkDerivation rec {
@@ -31,7 +31,7 @@ stdenv.mkDerivation rec {
     # if a release is tagged (which sometimes does not happen), it will
     # be in the format below.
     rev = "Release-${lib.replaceStrings ["."] ["-"] version}";
-    sha256 = "sha256-5JZgI5lnfX4JlBSEAL7Wv6uao/57GBaMqwgslJt9Bjk=";
+    hash = "sha256-5JZgI5lnfX4JlBSEAL7Wv6uao/57GBaMqwgslJt9Bjk=";
 
     # the repository's .gitattributes file contains the lines "/Tst/
     # export-ignore" and "/doc/ export-ignore" so some directories are
@@ -40,12 +40,11 @@ stdenv.mkDerivation rec {
   };
 
   configureFlags = [
+    "--enable-gfanlib"
     "--with-ntl=${ntl}"
-    "--disable-pyobject-module"
+    "--with-flint=${flint3}"
   ] ++ lib.optionals enableDocs [
     "--enable-doc-build"
-  ] ++ lib.optionals enableGfanlib [
-    "--enable-gfanlib"
   ];
 
   prePatch = ''
@@ -61,14 +60,15 @@ stdenv.mkDerivation rec {
   buildInputs = [
     # necessary
     gmp
+    flint3
     # by upstream recommended but optional
     ncurses
     readline
     ntl
-    flint3
+    mpfr
     lrcalc
+    # for gfanlib
     gfan
-  ] ++ lib.optionals enableGfanlib [
     cddlib
   ];
 
@@ -84,7 +84,7 @@ stdenv.mkDerivation rec {
     latex2html
     texinfo
     texliveSmall
-  ] ++ lib.optionals stdenv.isDarwin [ getconf ];
+  ] ++ lib.optionals stdenv.hostPlatform.isDarwin [ getconf ];
   depsBuildBuild = [ buildPackages.stdenv.cc ];
 
   preAutoreconf = ''
@@ -95,11 +95,13 @@ stdenv.mkDerivation rec {
       -i '{}' ';'
   '';
 
-  hardeningDisable = lib.optional stdenv.isi686 "stackprotector";
+  hardeningDisable = lib.optional stdenv.hostPlatform.isi686 "stackprotector";
 
   doCheck = true; # very basic checks, does not test any libraries
 
   installPhase = ''
+    # clean up any artefacts a previous non-sandboxed docbuild may have left behind
+    rm /tmp/conic.log /tmp/conic.tex /tmp/tropicalcurve*.tex || true
     make install
   '' + lib.optionalString enableDocs ''
     # Sage uses singular.info, which is not installed by default
@@ -118,8 +120,8 @@ stdenv.mkDerivation rec {
     "Buch/buch.lst"
     "Plural/short.lst"
     "Old/factor.tst"
-  ] ++ lib.optionals enableGfanlib [
     # tests that require gfanlib
+    # requires "DivRemIdU", a syzextra (undocumented) command
     "Short/ok_s.lst"
   ];
 
diff --git a/pkgs/applications/science/math/speedcrunch/default.nix b/pkgs/applications/science/math/speedcrunch/default.nix
index 021c1bedc348a..ed7339ab56775 100644
--- a/pkgs/applications/science/math/speedcrunch/default.nix
+++ b/pkgs/applications/science/math/speedcrunch/default.nix
@@ -32,6 +32,6 @@ mkDerivation rec {
     '';
     maintainers = with maintainers; [ gebner j0hax ];
     inherit (qtbase.meta) platforms;
-    broken = stdenv.isDarwin;
+    broken = stdenv.hostPlatform.isDarwin;
   };
 }
diff --git a/pkgs/applications/science/math/symmetrica/default.nix b/pkgs/applications/science/math/symmetrica/default.nix
index d6ec352d32a2f..f215ec0037d49 100644
--- a/pkgs/applications/science/math/symmetrica/default.nix
+++ b/pkgs/applications/science/math/symmetrica/default.nix
@@ -23,6 +23,10 @@ stdenv.mkDerivation rec {
     autoreconfHook
   ];
 
+  # clang warning: passing arguments to '...' without a prototype is deprecated
+  # in all versions of C and is not supported in C23.
+  CFLAGS = "-std=c99 -Wno-deprecated-non-prototype";
+
   enableParallelBuilding = true;
 
   meta = with lib; {
diff --git a/pkgs/applications/science/math/wolfram-engine/default.nix b/pkgs/applications/science/math/wolfram-engine/default.nix
index 685bc1bff3b18..c7a1b585379aa 100644
--- a/pkgs/applications/science/math/wolfram-engine/default.nix
+++ b/pkgs/applications/science/math/wolfram-engine/default.nix
@@ -2,8 +2,6 @@
 , stdenv
 , autoPatchelfHook
 , requireFile
-, callPackage
-, makeWrapper
 , alsa-lib
 , dbus
 , fontconfig
@@ -103,9 +101,9 @@ stdenv.mkDerivation rec {
     # Fix the installation script
     patchShebangs MathInstaller
     substituteInPlace MathInstaller \
-      --replace '`hostname`' "" \
-      --replace "chgrp" "# chgrp" \
-      --replace "chown" ": # chown"
+      --replace-fail '`hostname`' "" \
+      --replace-fail "chgrp" "# chgrp" \
+      --replace-fail "chown" ": # chown"
 
     # Install the desktop items
     export XDG_DATA_HOME="$out/share"
@@ -127,7 +125,7 @@ stdenv.mkDerivation rec {
       --set QT_XKB_CONFIG_ROOT "${xkeyboard_config}/share/X11/xkb"
     if ! isELF "$out/libexec/${dirName}/SystemFiles/FrontEnd/Binaries/Linux-x86-64/WolframPlayer"; then
       substituteInPlace $out/libexec/${dirName}/SystemFiles/FrontEnd/Binaries/Linux-x86-64/WolframPlayer \
-        --replace "TopDirectory=" "TopDirectory=$out/libexec/${dirName} #";
+        --replace-fail "TopDirectory=" "TopDirectory=$out/libexec/${dirName} #";
     fi
 
     for path in WolframPlayer wolframplayer; do
diff --git a/pkgs/applications/science/math/wolfram-engine/l10ns.nix b/pkgs/applications/science/math/wolfram-engine/l10ns.nix
index ae1886bae1543..de9b677ab17a4 100644
--- a/pkgs/applications/science/math/wolfram-engine/l10ns.nix
+++ b/pkgs/applications/science/math/wolfram-engine/l10ns.nix
@@ -4,10 +4,17 @@
 , majorVersion ? null
 }:
 
-let allVersions = with lib; flip map
+let allVersions = lib.flip map
   # N.B. Versions in this list should be ordered from newest to oldest.
   [
     {
+      version = "14.1.0";
+      lang = "en";
+      language = "English";
+      sha256 = "1kxdvm3i7nn3ws784y972h2br1n0y82kkkjvz7c5llssv6d3pgj8";
+      installer = "WolframEngine_14.1.0_LIN.sh";
+    }
+    {
       version = "13.3.0";
       lang = "en";
       language = "English";
@@ -45,7 +52,7 @@ let allVersions = with lib; flip map
   ]
   ({ version, lang, language, sha256, installer }: {
     inherit version lang;
-    name = "wolfram-engine-${version}" + optionalString (lang != "en") "-${lang}";
+    name = "wolfram-engine-${version}" + lib.optionalString (lang != "en") "-${lang}";
     src = requireFile {
       name = installer;
       message = ''
@@ -58,14 +65,12 @@ let allVersions = with lib; flip map
     };
   });
 minVersion =
-  with lib;
   if majorVersion == null
-  then elemAt (builtins.splitVersion (elemAt allVersions 0).version) 0
+  then lib.elemAt (builtins.splitVersion (lib.elemAt allVersions 0).version) 0
   else majorVersion;
 maxVersion = toString (1 + builtins.fromJSON minVersion);
 in
-with lib;
-findFirst (l: (l.lang == lang
+lib.findFirst (l: (l.lang == lang
                && l.version >= minVersion
                && l.version < maxVersion))
           (throw "Version ${minVersion} in language ${lang} not supported")
diff --git a/pkgs/applications/science/math/wolfram-engine/notebook.nix b/pkgs/applications/science/math/wolfram-engine/notebook.nix
index 85570eeca7fbc..07cd0afa3099d 100644
--- a/pkgs/applications/science/math/wolfram-engine/notebook.nix
+++ b/pkgs/applications/science/math/wolfram-engine/notebook.nix
@@ -1,4 +1,4 @@
-{ lib, stdenv, writeScriptBin, jupyter, wolfram-for-jupyter-kernel }:
+{ stdenv, writeScriptBin, jupyter, wolfram-for-jupyter-kernel }:
 
 let
   wolfram-jupyter = jupyter.override { definitions = { wolfram = wolfram-for-jupyter-kernel.definition; }; };
diff --git a/pkgs/applications/science/math/wxmaxima/default.nix b/pkgs/applications/science/math/wxmaxima/default.nix
index db2ff0c4a8444..2a6225eab7653 100644
--- a/pkgs/applications/science/math/wxmaxima/default.nix
+++ b/pkgs/applications/science/math/wxmaxima/default.nix
@@ -6,7 +6,7 @@
 , gettext
 , maxima
 , wxGTK
-, gnome
+, adwaita-icon-theme
 , glib
 }:
 
@@ -25,7 +25,7 @@ stdenv.mkDerivation (finalAttrs:{
     wxGTK
     maxima
     # So it won't embed svg files into headers.
-    gnome.adwaita-icon-theme
+    adwaita-icon-theme
     # So it won't crash under Sway.
     glib
   ];
diff --git a/pkgs/applications/science/math/yacas/default.nix b/pkgs/applications/science/math/yacas/default.nix
index 7fa2fe1a6075e..ad4e3f37d07ff 100644
--- a/pkgs/applications/science/math/yacas/default.nix
+++ b/pkgs/applications/science/math/yacas/default.nix
@@ -80,7 +80,7 @@ stdenv.mkDerivation rec {
     description = "Easy to use, general purpose Computer Algebra System${lib.optionalString enableGui ", built with GUI."}";
     homepage = "http://www.yacas.org/";
     license = lib.licenses.gpl2Plus;
-    maintainers = with lib.maintainers; [ viric ];
+    maintainers = [ ];
     platforms = with lib.platforms; linux;
   };
 }