1{
2 lib,
3 stdenv,
4 fetchurl,
5 fetchpatch,
6 texinfo,
7 perl,
8 python3,
9 makeWrapper,
10 autoreconfHook,
11 rlwrap ? null,
12 tk ? null,
13 gnuplot ? null,
14 lisp-compiler,
15}:
16
17let
18 # Allow to remove some executables from the $PATH of the wrapped binary
19 searchPath = lib.makeBinPath (
20 lib.filter (x: x != null) [
21 lisp-compiler
22 rlwrap
23 tk
24 gnuplot
25 ]
26 );
27in
28stdenv.mkDerivation (finalAttrs: {
29 pname = "maxima";
30 version = "5.47.0";
31
32 src = fetchurl {
33 url = "mirror://sourceforge/maxima/maxima-${finalAttrs.version}.tar.gz";
34 sha256 = "sha256-kQQCGyT9U+jAOpg1CctC6TepJejAyFwzXXcJoU/UD3o=";
35 };
36
37 nativeBuildInputs = [
38 autoreconfHook
39 lisp-compiler
40 makeWrapper
41 python3
42 texinfo
43 ];
44
45 strictDeps = true;
46
47 nativeCheckInputs = [
48 gnuplot
49 ];
50
51 postPatch = ''
52 substituteInPlace doc/info/Makefile.am --replace "/usr/bin/env perl" "${perl}/bin/perl"
53 '';
54
55 postInstall = ''
56 # Make sure that maxima can find its runtime dependencies.
57 for prog in "$out/bin/"*; do
58 wrapProgram "$prog" --prefix PATH ":" "$out/bin:${searchPath}"
59 done
60 # Move documentation into the right place.
61 mkdir -p $out/share/doc
62 ln -s ../maxima/${finalAttrs.version}/doc $out/share/doc/maxima
63 ''
64 + (lib.optionalString (lisp-compiler.pname == "ecl") ''
65 cp src/binary-ecl/maxima.fas* "$out/lib/maxima/${finalAttrs.version}/binary-ecl/"
66 '');
67
68 patches = [
69 # fix path to info dir (see https://trac.sagemath.org/ticket/11348)
70 (fetchpatch {
71 url = "https://raw.githubusercontent.com/sagemath/sage/07d6c37d18811e2b377a9689790a7c5e24da16ba/build/pkgs/maxima/patches/infodir.patch";
72 sha256 = "09v64n60f7i6frzryrj0zd056lvdpms3ajky4f9p6kankhbiv21x";
73 })
74
75 # fix https://sourceforge.net/p/maxima/bugs/2596/
76 (fetchpatch {
77 url = "https://raw.githubusercontent.com/sagemath/sage/07d6c37d18811e2b377a9689790a7c5e24da16ba/build/pkgs/maxima/patches/matrixexp.patch";
78 sha256 = "06961hn66rhjijfvyym21h39wk98sfxhp051da6gz0n9byhwc6zg";
79 })
80
81 # undo https://sourceforge.net/p/maxima/code/ci/f5e9b0f7eb122c4e48ea9df144dd57221e5ea0ca
82 # see https://trac.sagemath.org/ticket/13364#comment:93
83 (fetchpatch {
84 url = "https://raw.githubusercontent.com/sagemath/sage/07d6c37d18811e2b377a9689790a7c5e24da16ba/build/pkgs/maxima/patches/undoing_true_false_printing_patch.patch";
85 sha256 = "0fvi3rcjv6743sqsbgdzazy9jb6r1p1yq63zyj9fx42wd1hgf7yx";
86 })
87
88 ./5.47.0-CVE-2024-34490.patch
89 ];
90
91 # The test suite is disabled since 5.42.2 because of the following issues:
92 #
93 # Error(s) found:
94 # /build/maxima-5.44.0/share/linearalgebra/rtest_matrixexp.mac problems:
95 # (20 21 22)
96 # Tests that were expected to fail but passed:
97 # /build/maxima-5.44.0/share/vector/rtest_vect.mac problem:
98 # (19)
99 # 3 tests failed out of 16,184 total tests.
100 #
101 # These failures don't look serious. It would be nice to fix them, but I
102 # don't know how and probably won't have the time to find out.
103 doCheck = false; # try to re-enable after next version update
104
105 enableParallelBuilding = true;
106
107 passthru = {
108 inherit lisp-compiler;
109 };
110
111 meta = with lib; {
112 description = "Computer algebra system";
113 homepage = "http://maxima.sourceforge.net";
114 license = licenses.gpl2Plus;
115
116 longDescription = ''
117 Maxima is a fairly complete computer algebra system written in
118 lisp with an emphasis on symbolic computation. It is based on
119 DOE-MACSYMA and licensed under the GPL. Its abilities include
120 symbolic integration, 3D plotting, and an ODE solver.
121 '';
122 maintainers = with maintainers; [ doronbehar ];
123 platforms = platforms.unix;
124 };
125})