1{ lib, stdenv, fetchurl
2, coreutils, cctools
3, ncurses, libiconv, libX11, libuuid
4}:
5
6stdenv.mkDerivation (finalAttrs: {
7 pname = "chez-scheme";
8 version = "9.6.4";
9
10 src = fetchurl {
11 url = "https://github.com/cisco/ChezScheme/releases/download/v${finalAttrs.version}/csv${finalAttrs.version}.tar.gz";
12 hash = "sha256-9YJ2gvolnEeXX/4Hh4X7Vh5KXFT3ZDMe9mwyEyhDaF0=";
13 };
14
15 nativeBuildInputs = lib.optional stdenv.isDarwin cctools;
16 buildInputs = [ ncurses libiconv libX11 libuuid ];
17
18 enableParallelBuilding = true;
19
20 env.NIX_CFLAGS_COMPILE = lib.optionalString stdenv.cc.isGNU "-Wno-error=format-truncation";
21
22 /*
23 ** We patch out a very annoying 'feature' in ./configure, which
24 ** tries to use 'git' to update submodules.
25 **
26 ** We have to also fix a few occurrences to tools with absolute
27 ** paths in some helper scripts, otherwise the build will fail on
28 ** NixOS or in any chroot build.
29 */
30 patchPhase = ''
31 substituteInPlace ./configure \
32 --replace "git submodule init && git submodule update || exit 1" "true"
33
34 substituteInPlace ./workarea \
35 --replace "/bin/ln" ln \
36 --replace "/bin/cp" cp
37
38 substituteInPlace ./makefiles/installsh \
39 --replace "/usr/bin/true" "${coreutils}/bin/true"
40
41 substituteInPlace zlib/configure \
42 --replace "/usr/bin/libtool" libtool
43 '';
44
45 /*
46 ** Don't use configureFlags, since that just implicitly appends
47 ** everything onto a --prefix flag, which ./configure gets very angry
48 ** about.
49 **
50 ** Also, carefully set a manual workarea argument, so that we
51 ** can later easily find the machine type that we built Chez
52 ** for.
53 */
54 configurePhase = ''
55 ./configure --threads --installprefix=$out --installman=$out/share/man
56 '';
57
58 /*
59 ** Clean up some of the examples from the build output.
60 */
61 postInstall = ''
62 rm -rf $out/lib/csv${finalAttrs.version}/examples
63 '';
64
65 setupHook = ./setup-hook.sh;
66
67 meta = {
68 description = "A powerful and incredibly fast R6RS Scheme compiler";
69 homepage = "https://cisco.github.io/ChezScheme/";
70 license = lib.licenses.asl20;
71 maintainers = with lib.maintainers; [ thoughtpolice ];
72 platforms = lib.platforms.unix;
73 badPlatforms = [ "aarch64-linux" "aarch64-darwin" ];
74 };
75})