1{ build-asdf-system, lisp, quicklispPackagesFor, fixupFor, pkgs, ... }:
2
3let
4
5 inherit (pkgs.lib)
6 head
7 makeLibraryPath
8 makeSearchPath
9 setAttr
10 hasAttr
11 optionals
12 hasSuffix
13 splitString
14 ;
15
16 # Used by builds that would otherwise attempt to write into storeDir.
17 #
18 # Will run build two times, keeping all files created during the
19 # first run, exept the FASL's. Then using that directory tree as the
20 # source of the second run.
21 #
22 # E.g. cl-unicode creating .txt files during compilation
23 build-with-compile-into-pwd = args:
24 let
25 build = (build-asdf-system (args // { version = args.version + "-build"; }))
26 .overrideAttrs(o: {
27 buildPhase = with builtins; ''
28 mkdir __fasls
29 export LD_LIBRARY_PATH=${makeLibraryPath o.nativeLibs}:$LD_LIBRARY_PATH
30 export CLASSPATH=${makeSearchPath "share/java/*" o.javaLibs}:$CLASSPATH
31 export CL_SOURCE_REGISTRY=$CL_SOURCE_REGISTRY:$(pwd)//
32 export ASDF_OUTPUT_TRANSLATIONS="$(pwd):$(pwd)/__fasls:${storeDir}:${storeDir}"
33 ${o.lisp} ${o.buildScript}
34 '';
35 installPhase = ''
36 mkdir -pv $out
37 rm -rf __fasls
38 cp -r * $out
39 '';
40 });
41 in build-asdf-system (args // {
42 # Patches are already applied in `build`
43 patches = [];
44 src = build;
45 });
46
47 # A little hacky
48 isJVM = hasSuffix "abcl" (head (splitString " " lisp));
49
50 # Makes it so packages imported from Quicklisp can be re-used as
51 # lispLibs ofpackages in this file.
52 ql = quicklispPackagesFor { inherit lisp; fixup = fixupFor packages; };
53
54 packages = rec {
55
56 asdf = build-with-compile-into-pwd {
57 pname = "asdf";
58 version = "3.3.5.3";
59 src = pkgs.fetchzip {
60 url = "https://gitlab.common-lisp.net/asdf/asdf/-/archive/3.3.5.3/asdf-3.3.5.3.tar.gz";
61 sha256 = "0aw200awhg58smmbdmz80bayzmbm1a6547gv0wmc8yv89gjqldbv";
62 };
63 systems = [ "asdf" "uiop" ];
64 };
65
66 uiop = asdf.overrideLispAttrs(o: {
67 pname = "uiop";
68 });
69
70 cffi = let
71 jna = pkgs.fetchMavenArtifact {
72 groupId = "net.java.dev.jna";
73 artifactId = "jna";
74 version = "5.9.0";
75 sha256 = "0qbis8acv04fi902qzak1mbagqaxcsv2zyp7b8y4shs5nj0cgz7a";
76 };
77 in build-asdf-system {
78 src = pkgs.fetchzip {
79 url = "http://beta.quicklisp.org/archive/cffi/2021-04-11/cffi_0.24.1.tgz";
80 sha256 = "17ryim4xilb1rzxydfr7595dnhqkk02lmrbkqrkvi9091shi4cj3";
81 };
82 version = "0.24.1";
83 pname = "cffi";
84 lispLibs = with ql; [
85 alexandria
86 babel
87 trivial-features
88 ];
89 javaLibs = optionals isJVM [ jna ];
90 };
91
92 cffi-libffi = ql.cffi-libffi.overrideLispAttrs (o: {
93 src = pkgs.fetchzip {
94 url = "https://github.com/cffi/cffi/archive/3f842b92ef808900bf20dae92c2d74232c2f6d3a.tar.gz";
95 sha256 = "1jilvmbbfrmb23j07lwmkbffc6r35wnvas5s4zjc84i856ccclm2";
96 };
97 });
98
99 cl-unicode = build-with-compile-into-pwd {
100 pname = "cl-unicode";
101 version = "0.1.6";
102 src = pkgs.fetchzip {
103 url = "https://github.com/edicl/cl-unicode/archive/refs/tags/v0.1.6.tar.gz";
104 sha256 = "0ykx2s9lqfl74p1px0ik3l2izd1fc9jd1b4ra68s5x34rvjy0hza";
105 };
106 systems = [ "cl-unicode" ];
107 lispLibs = with ql; [
108 cl-ppcre
109 flexi-streams
110 ];
111 };
112
113 quri = build-asdf-system {
114 src = pkgs.stdenv.mkDerivation {
115 pname = "patched";
116 version = "source";
117 src = pkgs.fetchzip {
118 url = "http://beta.quicklisp.org/archive/quri/2021-04-11/quri-20210411-git.tgz";
119 sha256 = "1pkvpiwwhx2fcknr7x47h7036ypkg8xzsskqbl5z315ipfmi8s2m";
120 };
121
122 # fix build with ABCL
123 buildPhase = ''
124 sed -i "s,[#][.](asdf.*,#P\"$out/data/effective_tld_names.dat\")," src/etld.lisp
125 '';
126 installPhase = ''
127 mkdir -pv $out
128 cp -r * $out
129 '';
130 };
131 version = "20210411";
132 pname = "quri";
133 lispLibs = with ql; [
134 alexandria
135 babel
136 cl-utilities
137 split-sequence
138 ];
139 };
140
141 jzon = build-asdf-system {
142 src = pkgs.fetchzip {
143 url = "https://github.com/Zulu-Inuoe/jzon/archive/6b201d4208ac3f9721c461105b282c94139bed29.tar.gz";
144 sha256 = "01d4a78pjb1amx5amdb966qwwk9vblysm1li94n3g26mxy5zc2k3";
145 };
146 version = "0.0.0-20210905-6b201d4208";
147 pname = "jzon";
148 lispLibs = [
149 ql.closer-mop
150 ];
151 systems = [ "com.inuoe.jzon" ];
152 };
153
154 cl-notify = build-asdf-system {
155 pname = "cl-notify";
156 version = "20080904-138ca7038";
157 src = pkgs.fetchzip {
158 url = "https://repo.or.cz/cl-notify.git/snapshot/138ca703861f4a1fbccbed557f92cf4d213668a1.tar.gz";
159 sha256 = "0k6ns6fzvjcbpsqgx85r4g5m25fvrdw9481i9vyabwym9q8bbqwx";
160 };
161 lispLibs = [
162 cffi
163 ];
164 nativeLibs = [
165 pkgs.libnotify
166 ];
167 };
168
169 tuple = build-asdf-system {
170 pname = "tuple";
171 version = "b74bd067d";
172 src = pkgs.fetchzip {
173 url = "https://fossil.galkowski.xyz/tuple/tarball/b74bd067d4533ac0/tuple.tar.gz";
174 sha256 = "0dk356vkv6kwwcmc3j08x7143549m94rd66rpkzq8zkb31cg2va8";
175 };
176 };
177
178 cl-tar-file = build-asdf-system {
179 pname = "cl-tar-file";
180 version = "v0.2.1";
181 src = pkgs.fetchzip {
182 url = let
183 rev = "0c10bc82f14702c97a26dc25ce075b5d3a2347d1";
184 in "https://gitlab.common-lisp.net/cl-tar/cl-tar-file/-/archive/${rev}/cl-tar-file-${rev}.tar.gz";
185 sha256 = "0i8j05fkgdqy4c4pqj0c68sh4s3klpx9kc5wp73qwzrl3xqd2svy";
186 };
187 lispLibs = with ql; [
188 alexandria
189 babel
190 trivial-gray-streams
191 _40ants-doc
192 salza2
193 chipz
194 flexi-streams
195 parachute
196 ];
197 systems = [ "tar-file" "tar-file/test" ];
198 };
199
200 cl-tar = build-asdf-system {
201 pname = "cl-tar";
202 version = "v0.2.1";
203 src = pkgs.fetchzip {
204 url = let
205 rev = "7c6e07a10c93d9e311f087b5f6328cddd481669a";
206 in "https://gitlab.common-lisp.net/cl-tar/cl-tar/-/archive/${rev}/cl-tar-${rev}.tar.gz";
207 sha256 = "0wp23cs3i6a89dibifiz6559la5nk58d1n17xvbxq4nrl8cqsllf";
208 };
209 lispLibs = with ql; [
210 alexandria
211 babel
212 local-time
213 split-sequence
214 _40ants-doc
215 parachute
216 osicat
217 ] ++ [ cl-tar-file ];
218 systems = [
219 "tar"
220 "tar/common-extract"
221 "tar/simple-extract"
222 "tar/extract"
223 "tar/create"
224 "tar/docs"
225 "tar/test"
226 "tar/create-test"
227 "tar/extract-test"
228 "tar/simple-extract-test"
229 ];
230 };
231
232 cl-fuse = build-with-compile-into-pwd {
233 inherit (ql.cl-fuse) pname version src lispLibs;
234 nativeBuildInputs = [ pkgs.fuse ];
235 nativeLibs = [ pkgs.fuse ];
236 };
237
238 cl-containers = build-asdf-system {
239 inherit (ql.cl-containers) pname version src;
240 lispLibs = ql.cl-containers.lispLibs ++ [ ql.moptilities ];
241 systems = [ "cl-containers" "cl-containers/with-moptilities" ];
242 };
243
244 swank = build-with-compile-into-pwd {
245 inherit (ql.swank) pname version src lispLibs;
246 patches = [ ./patches/swank-pure-paths.patch ];
247 postConfigure = ''
248 substituteAllInPlace swank-loader.lisp
249 '';
250 };
251
252 clx-truetype = build-asdf-system {
253 pname = "clx-truetype";
254 version = "20160825-git";
255 src = pkgs.fetchzip {
256 url = "http://beta.quicklisp.org/archive/clx-truetype/2016-08-25/clx-truetype-20160825-git.tgz";
257 sha256 = "079hyp92cjkdfn6bhkxsrwnibiqbz4y4af6nl31lzw6nm91j5j37";
258 };
259 lispLibs = with ql; [
260 alexandria bordeaux-threads cl-aa cl-fad cl-paths cl-paths-ttf
261 cl-store cl-vectors clx trivial-features zpb-ttf
262 ];
263 };
264
265 mgl = build-asdf-system {
266 pname = "mgl";
267 version = "2021-10-07";
268 src = pkgs.fetchzip {
269 url = "https://github.com/melisgl/mgl/archive/e697791a9bcad3b6e7b3845246a2aa55238cfef7.tar.gz";
270 sha256 = "09sf7nq7nmf9q7bh3a5ygl2i2n0nhrx5fk2kv5ili0ckv7g9x72s";
271 };
272 lispLibs = with ql; [
273 alexandria closer-mop array-operations lla cl-reexport mgl-pax
274 named-readtables pythonic-string-reader
275 ] ++ [ mgl-mat ];
276 systems = [ "mgl" "mgl/test" ];
277 };
278
279 mgl-mat = build-asdf-system {
280 pname = "mgl-mat";
281 version = "2021-10-11";
282 src = pkgs.fetchzip {
283 url = "https://github.com/melisgl/mgl-mat/archive/3710858bc876b1b86e50f1db2abe719e92d810e7.tar.gz";
284 sha256 = "1aa2382mi55rp8pd31dz4d94yhfzh30vkggcvmvdfrr4ngffj0dx";
285 };
286 lispLibs = with ql; [
287 alexandria bordeaux-threads cffi cffi-grovel cl-cuda
288 flexi-streams ieee-floats lla mgl-pax static-vectors
289 trivial-garbage cl-fad
290 ];
291 systems = [ "mgl-mat" "mgl-mat/test" ];
292 };
293
294 mathkit = build-asdf-system {
295 inherit (ql.mathkit) pname version src asds lisp;
296 lispLibs = ql.mathkit.lispLibs ++ [ ql.sb-cga ];
297 };
298
299 nyxt-gtk = build-asdf-system {
300 inherit (ql.nyxt) pname lisp;
301 version = "2.2.4";
302
303 lispLibs = ql.nyxt.lispLibs ++ (with ql; [
304 cl-cffi-gtk cl-webkit2 mk-string-metrics
305 ]);
306
307 src = pkgs.fetchzip {
308 url = "https://github.com/atlas-engineer/nyxt/archive/2.2.4.tar.gz";
309 sha256 = "12l7ir3q29v06jx0zng5cvlbmap7p709ka3ik6x29lw334qshm9b";
310 };
311
312 buildInputs = [
313 pkgs.makeWrapper
314
315 # needed for GSETTINGS_SCHEMAS_PATH
316 pkgs.gsettings-desktop-schemas pkgs.glib pkgs.gtk3
317
318 # needed for XDG_ICON_DIRS
319 pkgs.gnome.adwaita-icon-theme
320 ];
321
322 buildScript = pkgs.writeText "build-nyxt.lisp" ''
323 (require :asdf)
324 (asdf:load-system :nyxt/gtk-application)
325 (sb-ext:save-lisp-and-die "nyxt" :executable t
326 #+sb-core-compression :compression
327 #+sb-core-compression t
328 :toplevel #'nyxt:entry-point)
329 '';
330
331 # Run with WEBKIT_FORCE_SANDBOX=0 if getting a runtime error in webkitgtk-2.34.4
332 installPhase = ql.nyxt.installPhase + ''
333 rm -v $out/nyxt
334 mkdir -p $out/bin
335 cp -v nyxt $out/bin
336 wrapProgram $out/bin/nyxt \
337 --prefix LD_LIBRARY_PATH : $LD_LIBRARY_PATH \
338 --prefix XDG_DATA_DIRS : $XDG_ICON_DIRS \
339 --prefix XDG_DATA_DIRS : $GSETTINGS_SCHEMAS_PATH \
340 --prefix GIO_EXTRA_MODULES ":" ${pkgs.dconf.lib}/lib/gio/modules/ \
341 --prefix GIO_EXTRA_MODULES ":" ${pkgs.glib-networking}/lib/gio/modules/
342 '';
343 };
344
345 nyxt = nyxt-gtk;
346
347 ltk = ql.ltk.overrideLispAttrs (o: {
348 src = pkgs.fetchzip {
349 url = "https://github.com/uthar/ltk/archive/f19162e76d6c7c2f51bd289b811d9ba20dd6555e.tar.gz";
350 sha256 = "0mzikv4abq9yqlj6dsji1wh34mjizr5prv6mvzzj29z1485fh1bj";
351 };
352 version = "f19162e76";
353 });
354
355 s-sql_slash_tests = ql.s-sql_slash_tests.overrideLispAttrs (o: {
356 lispLibs = o.lispLibs ++ [
357 ql.cl-postgres_slash_tests
358 ];
359 });
360
361 simple-date_slash_postgres-glue = ql.simple-date_slash_postgres-glue.overrideLispAttrs (o: {
362 lispLibs = o.lispLibs ++ [
363 ql.cl-postgres_slash_tests
364 ];
365 });
366
367 };
368
369in packages