From 70b827c60a43c4c7d9a71bc24319d037ab8f0bd8 Mon Sep 17 00:00:00 2001 From: amesgen Date: Fri, 10 Mar 2023 21:55:54 +0100 Subject: [PATCH] sage: fix build by downgrading maxima to 5.45 --- .../applications/science/math/maxima/5.45.nix | 126 ++++++++++++++++++ .../science/math/sage/default.nix | 2 +- pkgs/top-level/all-packages.nix | 4 + 3 files changed, 131 insertions(+), 1 deletion(-) create mode 100644 pkgs/applications/science/math/maxima/5.45.nix diff --git a/pkgs/applications/science/math/maxima/5.45.nix b/pkgs/applications/science/math/maxima/5.45.nix new file mode 100644 index 000000000000..cdf5421ce19d --- /dev/null +++ b/pkgs/applications/science/math/maxima/5.45.nix @@ -0,0 +1,126 @@ +{ lib +, stdenv +, fetchurl +, fetchpatch +, texinfo +, perl +, python3 +, makeWrapper +, autoreconfHook +, rlwrap ? null +, tk ? null +, gnuplot ? null +, lisp-compiler +}: + +let + # Allow to remove some executables from the $PATH of the wrapped binary + searchPath = lib.makeBinPath + (lib.filter (x: x != null) [ lisp-compiler rlwrap tk gnuplot ]); +in +stdenv.mkDerivation rec { + pname = "maxima"; + # old version temporarily kept for sage due to + # https://github.com/sagemath/sage/issues/33718 + version = "5.45.1"; + + src = fetchurl { + url = "mirror://sourceforge/${pname}/${pname}-${version}.tar.gz"; + sha256 = "sha256-/pAWJ2lwvvIUoaJENIVYZEUU1/36pPyLnQ6Hr8u059w="; + }; + + nativeBuildInputs = [ + autoreconfHook + lisp-compiler + makeWrapper + python3 + texinfo + ]; + + strictDeps = true; + + nativeCheckInputs = [ + gnuplot + ]; + + postPatch = '' + substituteInPlace doc/info/Makefile.am --replace "/usr/bin/env perl" "${perl}/bin/perl" + ''; + + postInstall = '' + # Make sure that maxima can find its runtime dependencies. + for prog in "$out/bin/"*; do + wrapProgram "$prog" --prefix PATH ":" "$out/bin:${searchPath}" + done + # Move emacs modules and documentation into the right place. + mkdir -p $out/share/emacs $out/share/doc + ln -s ../maxima/${version}/emacs $out/share/emacs/site-lisp + ln -s ../maxima/${version}/doc $out/share/doc/maxima + '' + + (lib.optionalString (lisp-compiler.pname == "ecl") '' + cp src/binary-ecl/maxima.fas* "$out/lib/maxima/${version}/binary-ecl/" + '') + ; + + patches = [ + # fix path to info dir (see https://trac.sagemath.org/ticket/11348) + (fetchpatch { + url = "https://git.sagemath.org/sage.git/plain/build/pkgs/maxima/patches/infodir.patch?id=07d6c37d18811e2b377a9689790a7c5e24da16ba"; + sha256 = "09v64n60f7i6frzryrj0zd056lvdpms3ajky4f9p6kankhbiv21x"; + }) + + # fix https://sourceforge.net/p/maxima/bugs/2596/ + (fetchpatch { + url = "https://git.sagemath.org/sage.git/plain/build/pkgs/maxima/patches/matrixexp.patch?id=07d6c37d18811e2b377a9689790a7c5e24da16ba"; + sha256 = "06961hn66rhjijfvyym21h39wk98sfxhp051da6gz0n9byhwc6zg"; + }) + + # undo https://sourceforge.net/p/maxima/code/ci/f5e9b0f7eb122c4e48ea9df144dd57221e5ea0ca + # see https://trac.sagemath.org/ticket/13364#comment:93 + (fetchpatch { + url = "https://git.sagemath.org/sage.git/plain/build/pkgs/maxima/patches/undoing_true_false_printing_patch.patch?id=07d6c37d18811e2b377a9689790a7c5e24da16ba"; + sha256 = "0fvi3rcjv6743sqsbgdzazy9jb6r1p1yq63zyj9fx42wd1hgf7yx"; + }) + ] ++ lib.optionals (lisp-compiler.pname == "ecl") [ + # build fasl, needed for ECL support + (fetchpatch { + url = "https://git.sagemath.org/sage.git/plain/build/pkgs/maxima/patches/maxima.system.patch?id=07d6c37d18811e2b377a9689790a7c5e24da16ba"; + sha256 = "18zafig8vflhkr80jq2ivk46k92dkszqlyq8cfmj0b2vcfjwwbar"; + }) + ]; + + # The test suite is disabled since 5.42.2 because of the following issues: + # + # Error(s) found: + # /build/maxima-5.44.0/share/linearalgebra/rtest_matrixexp.mac problems: + # (20 21 22) + # Tests that were expected to fail but passed: + # /build/maxima-5.44.0/share/vector/rtest_vect.mac problem: + # (19) + # 3 tests failed out of 16,184 total tests. + # + # These failures don't look serious. It would be nice to fix them, but I + # don't know how and probably won't have the time to find out. + doCheck = false; # try to re-enable after next version update + + enableParallelBuilding = true; + + passthru = { + inherit lisp-compiler; + }; + + meta = with lib; { + description = "Computer algebra system"; + homepage = "http://maxima.sourceforge.net"; + license = licenses.gpl2Plus; + + longDescription = '' + Maxima is a fairly complete computer algebra system written in + lisp with an emphasis on symbolic computation. It is based on + DOE-MACSYMA and licensed under the GPL. Its abilities include + symbolic integration, 3D plotting, and an ODE solver. + ''; + maintainers = with maintainers; [ doronbehar ]; + platforms = platforms.unix; + }; +} diff --git a/pkgs/applications/science/math/sage/default.nix b/pkgs/applications/science/math/sage/default.nix index eced57706d27..fa65ce0f3641 100644 --- a/pkgs/applications/science/math/sage/default.nix +++ b/pkgs/applications/science/math/sage/default.nix @@ -128,7 +128,7 @@ let singular = pkgs.singular.override { inherit flint; }; - maxima = pkgs.maxima.override { + maxima = pkgs.maxima-ecl-5_45.override { lisp-compiler = pkgs.ecl.override { # "echo syntax error | ecl > /dev/full 2>&1" segfaults in # ECL. We apply a patch to fix it (write_error.patch), but it diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 9965d33f2b47..05bb164647e2 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -37461,6 +37461,10 @@ with pkgs; maxima-ecl = maxima.override { lisp-compiler = ecl; }; + # old version temporarily kept for sage + maxima-ecl-5_45 = callPackage ../applications/science/math/maxima/5.45.nix { + lisp-compiler = ecl; + }; mxnet = callPackage ../applications/science/math/mxnet { inherit (linuxPackages) nvidia_x11;