nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{ lib
2, stdenv
3, fetchurl
4, fetchpatch
5, libtool
6, autoconf
7, automake
8, gmp
9, mpfr
10, libffi
11, makeWrapper
12, noUnicode ? false
13, gcc
14, threadSupport ? false
15, useBoehmgc ? true
16, boehmgc
17}:
18
19stdenv.mkDerivation rec {
20 pname = "ecl";
21 version = "16.1.2";
22
23 src = fetchurl {
24 url = "https://common-lisp.net/project/ecl/static/files/release/ecl-${version}.tgz";
25 sha256 = "sha256-LUgrGgpPvV2IFDRRcDInnYCMtkBeIt2R721zNTRGS5k=";
26 };
27
28 nativeBuildInputs = [ autoconf automake makeWrapper libtool ];
29 propagatedBuildInputs = [
30 libffi
31 gmp
32 mpfr
33 gcc
34 ] ++ lib.optionals useBoehmgc [
35 # replaces ecl's own gc which other packages can depend on, thus propagated
36 boehmgc
37 ];
38
39 configureFlags = [
40 (if threadSupport then "--enable-threads" else "--disable-threads")
41 "--with-gmp-incdir=${lib.getDev gmp}/include"
42 "--with-gmp-libdir=${lib.getLib gmp}/lib"
43 # -incdir, -libdir doesn't seem to be supported for libffi
44 "--with-libffi-prefix=${lib.getDev libffi}"
45 ] ++ lib.optional (! noUnicode) "--enable-unicode"
46 ;
47
48 patches = [
49 (fetchpatch {
50 # Avoid infinite loop, see https://gitlab.com/embeddable-common-lisp/ecl/issues/43 (fixed upstream)
51 name = "avoid-infinite-loop.patch";
52 url = "https://gitlab.com/embeddable-common-lisp/ecl/commit/caba1989f40ef917e7486f41b9cd5c7e3c5c2d79.patch";
53 sha256 = "07vw91psbc9gdn8grql46ra8lq3bgkzg5v480chnbryna4sv6lbb";
54 })
55 (fetchpatch {
56 # Fix getcwd with long pathnames
57 # Rebased version of
58 # https://gitlab.com/embeddable-common-lisp/ecl/commit/ac5f011f57a85a38627af154bc3ee7580e7fecd4.patch
59 name = "getcwd.patch";
60 url = "https://git.sagemath.org/sage.git/plain/build/pkgs/ecl/patches/16.1.2-getcwd.patch?id=07d6c37d18811e2b377a9689790a7c5e24da16ba";
61 sha256 = "1fbi8gn7rv8nqff5mpaijsrch3k3z7qc5cn4h1vl8qrr8xwqlqhb";
62 })
63 ./ecl-1.16.2-libffi-3.3-abi.patch
64 ];
65
66 hardeningDisable = [ "format" ];
67
68 postInstall = ''
69 sed -e 's/@[-a-zA-Z_]*@//g' -i $out/bin/ecl-config
70 wrapProgram "$out/bin/ecl" \
71 --prefix PATH ':' "${
72 lib.makeBinPath [
73 gcc # for the C compiler
74 gcc.bintools.bintools # for ar
75 ]
76 }" \
77 ''
78 # ecl 16.1.2 is too old to have -libdir for libffi and boehmgc, so we need to
79 # use NIX_LDFLAGS_BEFORE to make gcc find these particular libraries.
80 # Since it is missing even the prefix flag for boehmgc we also need to inject
81 # the correct -I flag via NIX_CFLAGS_COMPILE. Since we have access to it, we
82 # create the variables with suffixSalt (which seems to be necessary for
83 # NIX_CFLAGS_COMPILE even).
84 + lib.optionalString useBoehmgc ''
85 --prefix NIX_CFLAGS_COMPILE_${gcc.suffixSalt} ' ' "-I${lib.getDev boehmgc}/include" \
86 --prefix NIX_LDFLAGS_BEFORE_${gcc.bintools.suffixSalt} ' ' "-L${lib.getLib boehmgc}/lib" \
87 '' + ''
88 --prefix NIX_LDFLAGS_BEFORE_${gcc.bintools.suffixSalt} ' ' "-L${lib.getLib libffi}/lib"
89 '';
90
91 meta = with lib; {
92 description = "Lisp implementation aiming to be small, fast and easy to embed";
93 license = licenses.mit;
94 maintainers = lib.teams.lisp.members;
95 platforms = platforms.unix;
96 # never built on aarch64-darwin since first introduction in nixpkgs
97 broken = stdenv.isDarwin && stdenv.isAarch64;
98 };
99}