1{lib, stdenv, fetchurl, fetchpatch
2, libtool, autoconf, automake
3, texinfo
4, gmp, mpfr, libffi, makeWrapper
5, noUnicode ? false
6, gcc
7, threadSupport ? true
8, useBoehmgc ? false, boehmgc
9}:
10let
11 s = # Generated upstream information
12 rec {
13 baseName="ecl";
14 version="21.2.1";
15 name="${baseName}-${version}";
16 url="https://common-lisp.net/project/ecl/static/files/release/${name}.tgz";
17 sha256="000906nnq25177bgsfndiw3iqqgrjc9spk10hzk653sbz3f7anmi";
18 };
19 buildInputs = [
20 libtool autoconf automake texinfo makeWrapper
21 ];
22 propagatedBuildInputs = [
23 libffi gmp mpfr gcc
24 # replaces ecl's own gc which other packages can depend on, thus propagated
25 ] ++ lib.optionals useBoehmgc [
26 # replaces ecl's own gc which other packages can depend on, thus propagated
27 boehmgc
28 ];
29in
30stdenv.mkDerivation {
31 inherit (s) name version;
32 inherit buildInputs propagatedBuildInputs;
33
34 src = fetchurl {
35 inherit (s) url sha256;
36 };
37
38 patches = [
39 # https://gitlab.com/embeddable-common-lisp/ecl/-/merge_requests/1
40 (fetchpatch {
41 url = "https://git.sagemath.org/sage.git/plain/build/pkgs/ecl/patches/write_error.patch?h=9.2";
42 sha256 = "0hfxacpgn4919hg0mn4wf4m8r7y592r4gw7aqfnva7sckxi6w089";
43 })
44 ];
45
46 configureFlags = [
47 (if threadSupport then "--enable-threads" else "--disable-threads")
48 "--with-gmp-prefix=${gmp.dev}"
49 "--with-libffi-prefix=${libffi.dev}"
50 ]
51 ++
52 (lib.optional (! noUnicode)
53 "--enable-unicode")
54 ;
55
56 hardeningDisable = [ "format" ];
57
58 postInstall = ''
59 sed -e 's/@[-a-zA-Z_]*@//g' -i $out/bin/ecl-config
60 wrapProgram "$out/bin/ecl" \
61 --prefix PATH ':' "${gcc}/bin" \
62 --prefix NIX_LDFLAGS ' ' "-L${gmp.lib or gmp.out or gmp}/lib" \
63 --prefix NIX_LDFLAGS ' ' "-L${libffi.lib or libffi.out or libffi}/lib"
64 '';
65
66 meta = {
67 inherit (s) version;
68 description = "Lisp implementation aiming to be small, fast and easy to embed";
69 homepage = "https://common-lisp.net/project/ecl/";
70 license = lib.licenses.mit ;
71 maintainers = [lib.maintainers.raskin];
72 platforms = lib.platforms.unix;
73 changelog = "https://gitlab.com/embeddable-common-lisp/ecl/-/raw/${s.version}/CHANGELOG";
74 };
75}