1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
|
# there are the following linking sets:
# - boot (not installed): without modules, only used when building clisp
# - base (default): contains readline and i18n, regexp and syscalls modules
# by default
# - full: contains base plus modules in withModules
{
lib,
stdenv,
fetchFromGitLab,
autoconf,
automake,
bash,
libtool,
libsigsegv,
gettext,
ncurses,
zlib,
readline,
libffi,
libffcall,
libx11,
libxau,
libxt,
libxpm,
libxext,
xorgproto,
coreutils,
# build options
threadSupport ? (stdenv.hostPlatform.isx86 && !stdenv.hostPlatform.isDarwin),
x11Support ? (stdenv.hostPlatform.isx86 && !stdenv.hostPlatform.isDarwin),
dllSupport ? true,
withModules ? [
"asdf"
"rawsock"
]
++ lib.optionals stdenv.hostPlatform.isLinux [
"bindings/glibc"
"zlib"
]
++ lib.optional x11Support "clx/new-clx",
}:
assert
x11Support
-> (
libx11 != null
&& libxau != null
&& libxt != null
&& libxpm != null
&& xorgproto != null
&& libxext != null
);
let
ffcallAvailable = stdenv.hostPlatform.isLinux && (libffcall != null);
in
stdenv.mkDerivation {
version = "2.49.95-unstable-2024-12-28";
pname = "clisp";
src = fetchFromGitLab {
owner = "gnu-clisp";
repo = "clisp";
rev = "c3ec11bab87cfdbeba01523ed88ac2a16b22304d";
hash = "sha256-xXGx2FlS0l9huVMHqNbcAViLjxK8szOFPT0J8MpGp9w=";
};
strictDeps = true;
nativeBuildInputs = [
autoconf
automake
libtool
];
buildInputs = [
bash
libsigsegv
]
++ lib.optional (gettext != null) gettext
++ lib.optional (ncurses != null) ncurses
++ lib.optional (zlib != null) zlib
++ lib.optional (readline != null) readline
++ lib.optional (ffcallAvailable && (libffi != null)) libffi
++ lib.optional ffcallAvailable libffcall
++ lib.optionals x11Support [
libx11
libxau
libxt
libxpm
xorgproto
libxext
];
# First, replace port 9090 (rather low, can be used)
# with 64237 (much higher, IANA private area, not
# anything rememberable).
postPatch = ''
sed -e 's@9090@64237@g' -i tests/socket.tst
sed -i 's@/bin/pwd@${coreutils}&@' src/clisp-link.in
sed -i 's@1\.16\.2@${automake.version}@' src/aclocal.m4
find . -type f | xargs sed -e 's/-lICE/-lXau &/' -i
'';
configureFlags = [
"builddir"
]
++ lib.optional (!dllSupport) "--without-dynamic-modules"
++ lib.optional (readline != null) "--with-readline"
# --with-dynamic-ffi can only exist with --with-ffcall - foreign.d does not compile otherwise
++ lib.optional (ffcallAvailable && (libffi != null)) "--with-dynamic-ffi"
++ lib.optional ffcallAvailable "--with-ffcall"
++ lib.optional (!ffcallAvailable) "--without-ffcall"
++ map (x: " --with-module=" + x) withModules
++ lib.optional threadSupport "--with-threads=POSIX_THREADS";
preBuild = ''
sed -e '/avcall.h/a\#include "config.h"' -i src/foreign.d
sed -i -re '/ cfree /d' -i modules/bindings/glibc/linux.lisp
cd builddir
'';
doCheck = true;
postInstall = lib.optionalString (withModules != [ ]) ''
bash ./clisp-link add "$out"/lib/clisp*/base "$(dirname "$out"/lib/clisp*/base)"/full \
${lib.concatMapStrings (x: " " + x) withModules}
find "$out"/lib/clisp*/full -type l -name "*.o" | while read -r symlink; do
if [[ "$(readlink "$symlink")" =~ (.*\/builddir\/)(.*) ]]; then
ln -sf "../''${BASH_REMATCH[2]}" "$symlink"
fi
done
'';
env.NIX_CFLAGS_COMPILE = "-O0 -falign-functions=${
if stdenv.hostPlatform.is64bit then "8" else "4"
}";
meta = {
description = "ANSI Common Lisp Implementation";
homepage = "http://clisp.org";
mainProgram = "clisp";
teams = [ lib.teams.lisp ];
license = lib.licenses.gpl2Plus;
platforms = with lib.platforms; linux ++ darwin;
};
}
|