1{ fetchurl
2, lib
3, stdenv
4, makeWrapper
5, gnum4
6, texinfo
7, texLive
8, automake
9, autoconf
10, libtool
11, ghostscript
12, ncurses
13, enableX11 ? false, libX11
14}:
15
16let
17 version = "12.1";
18 bootstrapFromC = ! ((stdenv.isLinux && stdenv.isAarch64) || stdenv.isx86_64);
19
20 arch = if stdenv.isLinux && stdenv.isAarch64 then
21 "-aarch64le"
22 else
23 "-x86-64";
24in
25stdenv.mkDerivation {
26 pname = "mit-scheme" + lib.optionalString enableX11 "-x11";
27 inherit version;
28
29 # MIT/GNU Scheme is not bootstrappable, so it's recommended to compile from
30 # the platform-specific tarballs, which contain pre-built binaries. It
31 # leads to more efficient code than when building the tarball that contains
32 # generated C code instead of those binaries.
33 src =
34 if stdenv.isLinux && stdenv.isAarch64
35 then fetchurl {
36 url = "mirror://gnu/mit-scheme/stable.pkg/${version}/mit-scheme-${version}-aarch64le.tar.gz";
37 sha256 = "12ra9bc93x8g07impbd8jr6djjzwpb9qvh9zhxvvrba3332zx3vh";
38 } else fetchurl {
39 url = "mirror://gnu/mit-scheme/stable.pkg/${version}/mit-scheme-${version}-x86-64.tar.gz";
40 sha256 = "035f92vni0vqmgj9hq2i7vwasz7crx52wll4823vhfkm1qdv5ywc";
41 };
42
43 buildInputs = [ ncurses ] ++ lib.optionals enableX11 [ libX11 ];
44
45 configurePhase = ''
46 runHook preConfigure
47 (cd src && ./configure)
48 (cd doc && ./configure)
49 runHook postConfigure
50 '';
51
52 env.NIX_CFLAGS_COMPILE = toString [
53 # Needed with GCC 12
54 "-Wno-error=array-parameter"
55 "-Wno-error=use-after-free"
56 ];
57
58 buildPhase = ''
59 runHook preBuild
60 cd src
61
62 ${if bootstrapFromC
63 then "./etc/make-liarc.sh --prefix=$out"
64 else "make compile-microcode"}
65
66 cd ../doc
67
68 make
69
70 cd ..
71
72 runHook postBuild
73 '';
74
75
76 installPhase = ''
77 runHook preInstall
78 make prefix=$out install -C src
79 make prefix=$out install -C doc
80 runHook postInstall
81 '';
82
83 postFixup = ''
84 wrapProgram $out/bin/mit-scheme${arch}-${version} --set MITSCHEME_LIBRARY_PATH \
85 $out/lib/mit-scheme${arch}-${version}
86 '';
87
88 nativeBuildInputs = [ makeWrapper gnum4 texinfo texLive automake ghostscript autoconf libtool ];
89
90 # XXX: The `check' target doesn't exist.
91 doCheck = false;
92
93 meta = with lib; {
94 description = "MIT/GNU Scheme, a native code Scheme compiler";
95
96 longDescription =
97 '' MIT/GNU Scheme is an implementation of the Scheme programming
98 language, providing an interpreter, compiler, source-code debugger,
99 integrated Emacs-like editor, and a large runtime library. MIT/GNU
100 Scheme is best suited to programming large applications with a rapid
101 development cycle.
102 '';
103
104 homepage = "https://www.gnu.org/software/mit-scheme/";
105
106 license = licenses.gpl2Plus;
107
108 maintainers = [ ];
109
110 # Build fails on Cygwin and Darwin:
111 # <http://article.gmane.org/gmane.lisp.scheme.mit-scheme.devel/489>.
112 platforms = platforms.gnu ++ platforms.linux ++ platforms.freebsd;
113 };
114}