1# do not add pkgs, it messes up splicing
2{
3 stdenv,
4 cargo,
5 cmake,
6
7 ast-grep,
8 which,
9 findutils,
10 coreutils,
11 curl,
12 dbus,
13 expat,
14 fd,
15 fetchFromGitHub,
16 fetchpatch,
17 fetchurl,
18 fzf,
19 glib,
20 glibc,
21 gmp,
22 gnulib,
23 gnum4,
24 gobject-introspection,
25 imagemagick,
26 installShellFiles,
27 lib,
28 libevent,
29 libiconv,
30 libmpack,
31 libmysqlclient,
32 libpsl,
33 libpq,
34 libuuid,
35 libxcrypt,
36 libyaml,
37 lua-language-server,
38 luajitPackages,
39 mariadb,
40 mpfr,
41 neovim-unwrapped,
42 oniguruma,
43 openldap,
44 openssl,
45 pcre,
46 pkg-config,
47 readline,
48 ripgrep,
49 rustPlatform,
50 sqlite,
51 tree-sitter,
52 unbound,
53 unzip,
54 versionCheckHook,
55 vimPlugins,
56 yajl,
57 zip,
58 zlib,
59 zziplib,
60 writableTmpDirAsHomeHook,
61 gitMinimal,
62 getopt,
63}:
64
65final: prev:
66let
67 inherit (prev)
68 luaOlder
69 luaAtLeast
70 lua
71 isLuaJIT
72 ;
73in
74{
75 argparse = prev.argparse.overrideAttrs (oa: {
76
77 doCheck = true;
78 nativeCheckInputs = [ final.busted ];
79
80 checkPhase = ''
81 runHook preCheck
82 export LUA_PATH="src/?.lua;$LUA_PATH"
83 busted spec/
84 runHook postCheck
85 '';
86 });
87 ##########################################3
88 #### manual fixes for generated packages
89 ##########################################3
90 busted = prev.busted.overrideAttrs (oa: {
91 nativeBuildInputs = oa.nativeBuildInputs ++ [
92 installShellFiles
93 ];
94 postConfigure = ''
95 substituteInPlace ''${rockspecFilename} \
96 --replace-fail "'lua_cliargs = 3.0'," "'lua_cliargs >= 3.0-1',"
97 '';
98 postInstall = ''
99 installShellCompletion --cmd busted \
100 --zsh completions/zsh/_busted \
101 --bash completions/bash/busted.bash
102 '';
103 });
104
105 cqueues = prev.cqueues.overrideAttrs (oa: {
106 # Parse out a version number without the Lua version inserted
107 version =
108 let
109 version' = prev.cqueues.version;
110 rel = lib.splitVersion version';
111 date = lib.head rel;
112 rev = lib.last (lib.splitString "-" (lib.last rel));
113 in
114 "${date}-${rev}";
115 __intentionallyOverridingVersion = true;
116
117 meta.broken = luaOlder "5.1" || luaAtLeast "5.5";
118
119 nativeBuildInputs = oa.nativeBuildInputs ++ [
120 gnum4
121 ];
122
123 externalDeps = [
124 {
125 name = "CRYPTO";
126 dep = openssl;
127 }
128 {
129 name = "OPENSSL";
130 dep = openssl;
131 }
132 ];
133
134 # Upstream rockspec is pointlessly broken into separate rockspecs, per Lua
135 # version, which doesn't work well for us, so modify it
136 postConfigure =
137 let
138 inherit (final.cqueues) pname version;
139 in
140 ''
141 # 'all' target auto-detects correct Lua version, which is fine for us as
142 # we only have the right one available :)
143 sed -Ei ''${rockspecFilename} \
144 -e 's|lua == 5.[[:digit:]]|lua >= 5.1, <= 5.4|' \
145 -e 's|build_target = "[^"]+"|build_target = "all"|' \
146 -e 's|version = "[^"]+"|version = "${version}"|'
147 specDir=$(dirname ''${rockspecFilename})
148 cp ''${rockspecFilename} "$specDir/${pname}-${version}.rockspec"
149 rockspecFilename="$specDir/${pname}-${version}.rockspec"
150 '';
151 });
152
153 fzf-lua = prev.fzf-lua.overrideAttrs {
154 # FIXME: Darwin flaky tests
155 # address already in use on second test run
156 # Previewer transient failure
157 doCheck = !stdenv.hostPlatform.isDarwin;
158 checkInputs = [
159 fd
160 fzf
161 getopt
162 ripgrep
163 ];
164 nativeCheckInputs = [
165 neovim-unwrapped
166 writableTmpDirAsHomeHook
167 ];
168 checkPhase = ''
169 runHook preCheck
170
171 # Linking the dependencies since makefile wants to clone them each time
172 # for `make deps`
173 mkdir -p deps
174 ln -s ${vimPlugins.mini-nvim} deps/mini.nvim
175 ln -s ${vimPlugins.nvim-web-devicons} deps/nvim-web-devicons
176
177 # TODO: remove with new nvim-web-devicons release
178 # Disabled devicons test because we have old version as dep and fzf-lua checks for a new icon
179 substituteInPlace tests/files_spec.lua \
180 --replace-fail \
181 "T[\"files\"][\"icons\"] = new_set({ parametrize = { { \"devicons\" }, { \"mini\" } } })" \
182 "T[\"files\"][\"icons\"] = new_set({ parametrize = { { \"mini\" } } })"
183
184 # TODO: Figure out why 2 files extra
185 substituteInPlace tests/screenshots/tests-files_spec.lua---files---executable---1-+-args-{-\'fd\'-} \
186 --replace-fail "96" "98"
187
188 make test
189
190 runHook postCheck
191 '';
192 };
193
194 # Until https://github.com/swarn/fzy-lua/pull/8 is merged,
195 # we have to invoke busted manually
196 fzy = prev.fzy.overrideAttrs (oa: {
197 doCheck = true;
198 nativeCheckInputs = [ final.busted ];
199 checkPhase = ''
200 busted
201 '';
202 });
203
204 grug-far-nvim = prev.grug-far-nvim.overrideAttrs ({
205 doCheck = lua.luaversion == "5.1" && !stdenv.hostPlatform.isDarwin;
206 nativeCheckInputs = [
207 final.busted
208 final.mini-test
209 final.nlua
210 ripgrep
211 neovim-unwrapped
212 ];
213
214 # feel free to disable the checks. They are mostly screenshot based
215 checkPhase = ''
216 runHook preCheck
217 # feel free to disable/adjust the tests
218 rm tests/base/test_apply.lua tests/base/test_vimscript_interpreter.lua
219
220 # Dependencies needed in special location
221 mkdir -p deps/{ripgrep,astgrep}
222 mkdir {temp_test_dir,temp_history_dir}
223 ln -s ${lib.getExe ripgrep} deps/ripgrep/rg
224 ln -s ${lib.getExe ast-grep} deps/astgrep/ast-grep
225 ln -s ${vimPlugins.mini-nvim} deps/mini.nvim
226
227 # Update dependency check to respect packaged version
228 substituteInPlace lua/grug-far/test/dependencies.lua \
229 --replace-fail "local RG_VERSION = '14.1.0'" "local RG_VERSION = '${lib.getVersion ripgrep}'" \
230 --replace-fail "local SG_VERSION = '0.35.0'" "local SG_VERSION = '${lib.getVersion ast-grep}'"
231
232 make test dir=base
233 runHook postCheck
234 '';
235
236 });
237
238 http = prev.http.overrideAttrs (oa: {
239 /*
240 TODO: separate docs derivation? (pandoc is heavy)
241 nativeBuildInputs = [ pandoc ];
242 makeFlags = [ "-C doc" "lua-http.html" "lua-http.3" ];
243 */
244 });
245
246 image-nvim = prev.image-nvim.overrideAttrs (oa: {
247 propagatedBuildInputs = [
248 lua
249 luajitPackages.magick
250 ];
251 });
252
253 ldbus = prev.ldbus.overrideAttrs (oa: {
254 luarocksConfig = oa.luarocksConfig // {
255 variables = {
256 DBUS_DIR = "${dbus.lib}";
257 DBUS_ARCH_INCDIR = "${dbus.lib}/lib/dbus-1.0/include";
258 DBUS_INCDIR = "${dbus.dev}/include/dbus-1.0";
259 };
260 };
261 buildInputs = [
262 dbus
263 ];
264 });
265
266 ljsyscall = prev.ljsyscall.overrideAttrs (oa: rec {
267 version = "unstable-20180515";
268 # package hasn't seen any release for a long time
269 src = fetchFromGitHub {
270 owner = "justincormack";
271 repo = "ljsyscall";
272 rev = "e587f8c55aad3955dddab3a4fa6c1968037b5c6e";
273 sha256 = "06v52agqyziwnbp2my3r7liv245ddmb217zmyqakh0ldjdsr8lz4";
274 };
275 knownRockspec = "rockspec/ljsyscall-scm-1.rockspec";
276 # actually library works fine with lua 5.2
277 preConfigure = ''
278 sed -i 's/lua == 5.1/lua >= 5.1, < 5.3/' ${knownRockspec}
279 '';
280 meta.broken = luaOlder "5.1" || luaAtLeast "5.3";
281
282 propagatedBuildInputs = oa.propagatedBuildInputs ++ lib.optional (!isLuaJIT) final.luaffi;
283 });
284
285 lgi = prev.lgi.overrideAttrs (oa: {
286 nativeBuildInputs = oa.nativeBuildInputs ++ [
287 pkg-config
288 ];
289 buildInputs = [
290 glib
291 gobject-introspection
292 ];
293 patches = [
294 (fetchpatch {
295 name = "lgi-find-cairo-through-typelib.patch";
296 url = "https://github.com/psychon/lgi/commit/46a163d9925e7877faf8a4f73996a20d7cf9202a.patch";
297 sha256 = "0gfvvbri9kyzhvq3bvdbj2l6mwvlz040dk4mrd5m9gz79f7w109c";
298 })
299 ];
300
301 # https://github.com/lgi-devs/lgi/pull/300
302 postPatch = ''
303 substituteInPlace lgi/Makefile tests/Makefile \
304 --replace 'PKG_CONFIG =' 'PKG_CONFIG ?='
305 '';
306
307 # there is only a rockspec.in in the repo, the actual rockspec must be generated
308 preConfigure = ''
309 make rock
310 '';
311
312 # Lua 5.4 support is experimental at the moment, see
313 # https://github.com/lgi-devs/lgi/pull/249
314 meta.broken = luaOlder "5.1" || luaAtLeast "5.4";
315 });
316
317 llscheck = prev.llscheck.overrideAttrs (oa: {
318 propagatedBuildInputs = oa.propagatedBuildInputs ++ [ lua-language-server ];
319 });
320
321 lmathx = prev.luaLib.overrideLuarocks prev.lmathx (
322 drv:
323 if luaAtLeast "5.1" && luaOlder "5.2" then
324 {
325 version = "20120430.51-1";
326 knownRockspec =
327 (fetchurl {
328 url = "mirror://luarocks/lmathx-20120430.51-1.rockspec";
329 sha256 = "148vbv2g3z5si2db7rqg5bdily7m4sjyh9w6r3jnx3csvfaxyhp0";
330 }).outPath;
331 src = fetchurl {
332 url = "https://web.tecgraf.puc-rio.br/~lhf/ftp/lua/5.1/lmathx.tar.gz";
333 sha256 = "0sa553d0zlxhvpsmr4r7d841f16yq4wr3fg7i07ibxkz6yzxax51";
334 };
335 }
336 else if luaAtLeast "5.2" && luaOlder "5.3" then
337 {
338 version = "20120430.52-1";
339 knownRockspec =
340 (fetchurl {
341 url = "mirror://luarocks/lmathx-20120430.52-1.rockspec";
342 sha256 = "14rd625sipakm72wg6xqsbbglaxyjba9nsajsfyvhg0sz8qjgdya";
343 }).outPath;
344 src = fetchurl {
345 url = "http://www.tecgraf.puc-rio.br/~lhf/ftp/lua/5.2/lmathx.tar.gz";
346 sha256 = "19dwa4z266l2njgi6fbq9rak4rmx2fsx1s0p9sl166ar3mnrdwz5";
347 };
348 }
349 else
350 {
351 disabled = luaOlder "5.1" || luaAtLeast "5.5";
352 # works fine with 5.4 as well
353 postConfigure = ''
354 substituteInPlace ''${rockspecFilename} \
355 --replace 'lua ~> 5.3' 'lua >= 5.3, < 5.5'
356 '';
357 }
358 );
359
360 lmpfrlib = prev.lmpfrlib.overrideAttrs (oa: {
361 externalDeps = [
362 {
363 name = "GMP";
364 dep = gmp;
365 }
366 {
367 name = "MPFR";
368 dep = mpfr;
369 }
370 ];
371 unpackPhase = ''
372 cp $src $(stripHash $src)
373 '';
374 });
375
376 lrexlib-gnu = prev.lrexlib-gnu.overrideAttrs (oa: {
377 buildInputs = oa.buildInputs ++ [
378 gnulib
379 ];
380 });
381
382 lrexlib-oniguruma = prev.lrexlib-oniguruma.overrideAttrs (oa: {
383 externalDeps = [
384 {
385 name = "ONIG";
386 dep = oniguruma;
387 }
388 ];
389 });
390
391 lrexlib-pcre = prev.lrexlib-pcre.overrideAttrs (oa: {
392 externalDeps = [
393 {
394 name = "PCRE";
395 dep = pcre;
396 }
397 ];
398 });
399
400 lrexlib-posix = prev.lrexlib-posix.overrideAttrs (oa: {
401 buildInputs = oa.buildInputs ++ [
402 glibc.dev
403 ];
404 });
405
406 luacheck = prev.luacheck.overrideAttrs (oa: {
407 meta = oa.meta // {
408 mainProgram = "luacheck";
409 };
410 });
411
412 lua-curl = prev.lua-curl.overrideAttrs (oa: {
413 buildInputs = oa.buildInputs ++ [
414 curl.dev
415 ];
416 });
417
418 lua-iconv = prev.lua-iconv.overrideAttrs (oa: {
419 buildInputs = oa.buildInputs ++ [
420 libiconv
421 ];
422 });
423
424 lua-lsp = prev.lua-lsp.overrideAttrs (oa: {
425 # until Alloyed/lua-lsp#28
426 postConfigure = ''
427 substituteInPlace ''${rockspecFilename} \
428 --replace '"dkjson ~> 2.5",' '"dkjson >= 2.5",'
429 '';
430 });
431
432 lua-resty-jwt = prev.lua-resty-jwt.overrideAttrs (oa: {
433 src = fetchFromGitHub {
434 owner = "cdbattags";
435 repo = "lua-resty-jwt";
436 rev = "v0.2.3";
437 hash = "sha256-5lnr0ka6ijfujiRjqwCPb6jzItXx45FIN8CvhR/KiB8=";
438 fetchSubmodules = true;
439 };
440 });
441
442 lua-zlib = prev.lua-zlib.overrideAttrs (oa: {
443 buildInputs = oa.buildInputs ++ [
444 zlib.dev
445 ];
446 meta = oa.meta // {
447 broken = luaOlder "5.1" || luaAtLeast "5.4";
448 };
449 });
450
451 luadbi-mysql = prev.luadbi-mysql.overrideAttrs (oa: {
452
453 luarocksConfig = lib.recursiveUpdate oa.luarocksConfig {
454 variables = {
455 MYSQL_INCDIR = "${lib.getDev libmysqlclient}/include/";
456 MYSQL_LIBDIR = "${lib.getLib libmysqlclient}/lib/";
457 };
458 };
459 buildInputs = oa.buildInputs ++ [
460 mariadb.client
461 libmysqlclient
462 ];
463 });
464
465 luadbi-postgresql = prev.luadbi-postgresql.overrideAttrs (oa: {
466 buildInputs = oa.buildInputs ++ [
467 (lib.getDev libpq)
468 ];
469 });
470
471 luadbi-sqlite3 = prev.luadbi-sqlite3.overrideAttrs (oa: {
472 externalDeps = [
473 {
474 name = "SQLITE";
475 dep = sqlite;
476 }
477 ];
478 });
479
480 luaevent = prev.luaevent.overrideAttrs (oa: {
481 propagatedBuildInputs = oa.propagatedBuildInputs ++ [
482 final.luasocket
483 ];
484 externalDeps = [
485 {
486 name = "EVENT";
487 dep = libevent;
488 }
489 ];
490 meta.broken = luaOlder "5.1" || luaAtLeast "5.4";
491 });
492
493 luaexpat = prev.luaexpat.overrideAttrs (_: {
494 externalDeps = [
495 {
496 name = "EXPAT";
497 dep = expat;
498 }
499 ];
500 });
501
502 # TODO Somehow automatically amend buildInputs for things that need luaffi
503 # but are in luajitPackages?
504 luaffi = prev.luaffi.overrideAttrs (oa: {
505 # The packaged .src.rock version is pretty old, and doesn't work with Lua 5.3
506 src = fetchFromGitHub {
507 owner = "facebook";
508 repo = "luaffifb";
509 rev = "532c757e51c86f546a85730b71c9fef15ffa633d";
510 sha256 = "1nwx6sh56zfq99rcs7sph0296jf6a9z72mxknn0ysw9fd7m1r8ig";
511 };
512 knownRockspec = with prev.luaffi; "${pname}-${version}.rockspec";
513 meta.broken = luaOlder "5.1" || luaAtLeast "5.4" || isLuaJIT;
514 });
515
516 lualdap = prev.lualdap.overrideAttrs (_: {
517 externalDeps = [
518 {
519 name = "LDAP";
520 dep = openldap;
521 }
522 ];
523 });
524
525 lualine-nvim = prev.lualine-nvim.overrideAttrs (_: {
526 doCheck = lua.luaversion == "5.1";
527 nativeCheckInputs = [
528 final.nlua
529 final.busted
530 final.nvim-web-devicons
531 gitMinimal
532 writableTmpDirAsHomeHook
533 ];
534 checkPhase = ''
535 runHook preCheck
536 busted --lua=nlua --lpath='lua/?.lua' --lpath='lua/?/init.lua' tests/
537 runHook postCheck
538 '';
539 });
540
541 luaossl = prev.luaossl.overrideAttrs (_: {
542 externalDeps = [
543 {
544 name = "CRYPTO";
545 dep = openssl;
546 }
547 {
548 name = "OPENSSL";
549 dep = openssl;
550 }
551 ];
552 });
553
554 luaposix = prev.luaposix.overrideAttrs (_: {
555 externalDeps = [
556 {
557 name = "CRYPT";
558 dep = libxcrypt;
559 }
560 ];
561 });
562
563 luaprompt = prev.luaprompt.overrideAttrs (oa: {
564 externalDeps = [
565 {
566 name = "READLINE";
567 dep = readline;
568 }
569 {
570 name = "HISTORY";
571 dep = readline;
572 }
573 ];
574
575 nativeBuildInputs = oa.nativeBuildInputs ++ [ installShellFiles ];
576
577 postInstall = ''
578 installManPage luap.1
579 '';
580 });
581
582 # As a nix user, use this derivation instead of "luarocks_bootstrap"
583 luarocks = prev.luarocks.overrideAttrs (oa: {
584
585 nativeBuildInputs = oa.nativeBuildInputs ++ [
586 installShellFiles
587 lua
588 unzip
589 versionCheckHook
590 ];
591 # cmake is just to compile packages with "cmake" buildType, not luarocks itself
592 dontUseCmakeConfigure = true;
593
594 doInstallCheck = true;
595 versionCheckProgramArg = "--version";
596
597 propagatedBuildInputs = [
598 zip
599 unzip
600 cmake
601 ];
602
603 postInstall = lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
604 installShellCompletion --cmd luarocks \
605 --bash <($out/bin/luarocks completion bash) \
606 --fish <($out/bin/luarocks completion fish) \
607 --zsh <($out/bin/luarocks completion zsh)
608
609 installShellCompletion --cmd luarocks-admin \
610 --bash <($out/bin/luarocks-admin completion bash) \
611 --fish <($out/bin/luarocks-admin completion fish) \
612 --zsh <($out/bin/luarocks-admin completion zsh)
613 '';
614
615 meta = oa.meta // {
616 mainProgram = "luarocks";
617 };
618
619 });
620
621 luasec = prev.luasec.overrideAttrs (oa: {
622 externalDeps = [
623 {
624 name = "OPENSSL";
625 dep = openssl;
626 }
627 ];
628 });
629
630 luasql-sqlite3 = prev.luasql-sqlite3.overrideAttrs (oa: {
631 externalDeps = [
632 {
633 name = "SQLITE";
634 dep = sqlite;
635 }
636 ];
637 });
638
639 luasystem = prev.luasystem.overrideAttrs (
640 oa:
641 lib.optionalAttrs stdenv.hostPlatform.isLinux {
642 buildInputs = [ glibc.out ];
643 }
644 );
645
646 luazip = prev.luazip.overrideAttrs (oa: {
647 buildInputs = oa.buildInputs ++ [
648 zziplib
649 ];
650 });
651
652 # lua-resty-session = prev.lua-resty-session.overrideAttrs (oa: {
653 # # lua_pack and lua-ffi-zlib are unpackaged, causing this package to not evaluate
654 # meta.broken = true;
655 # });
656
657 lua-yajl = prev.lua-yajl.overrideAttrs (oa: {
658 buildInputs = oa.buildInputs ++ [
659 yajl
660 ];
661 });
662
663 luaunbound = prev.luaunbound.overrideAttrs (oa: {
664 externalDeps = [
665 {
666 name = "libunbound";
667 dep = unbound;
668 }
669 ];
670 });
671
672 lua-subprocess = prev.lua-subprocess.overrideAttrs (oa: {
673 meta.broken = luaOlder "5.1" || luaAtLeast "5.4";
674 });
675
676 lua-rtoml = prev.lua-rtoml.overrideAttrs (oa: {
677
678 cargoDeps = rustPlatform.fetchCargoVendor {
679 src = oa.src;
680 hash = "sha256-7mFn4dLgaxfAxtPFCc3VzcBx2HuywcZTYqCGTbaGS0k=";
681 };
682
683 propagatedBuildInputs = oa.propagatedBuildInputs ++ [
684 cargo
685 rustPlatform.cargoSetupHook
686 ];
687
688 # ld: symbol(s) not found for architecture arm64
689 # clang-16: error: linker command failed with exit code 1 (use -v to see invocation)
690 meta.broken = stdenv.hostPlatform.isDarwin;
691 });
692
693 lush-nvim = prev.lush-nvim.overrideAttrs {
694 # Remove dangling symlink created during installation because we don't copy the source CREATE.md it links to
695 # Using a generic method because path changes depending on if building luaPackage or vimPlugin
696 postInstall = ''
697 find -L $out -type l -name "README.md" -print -delete
698 '';
699 };
700
701 luuid = prev.luuid.overrideAttrs (oa: {
702 externalDeps = [
703 {
704 name = "LIBUUID";
705 dep = libuuid;
706 }
707 ];
708 # Trivial patch to make it work in both 5.1 and 5.2. Basically just the
709 # tiny diff between the two upstream versions placed behind an #if.
710 # Upstreams:
711 # 5.1: http://webserver2.tecgraf.puc-rio.br/~lhf/ftp/lua/5.1/luuid.tar.gz
712 # 5.2: http://webserver2.tecgraf.puc-rio.br/~lhf/ftp/lua/5.2/luuid.tar.gz
713 patchFlags = [ "-p2" ];
714 patches = [
715 ./luuid.patch
716 ];
717 postConfigure = ''
718 sed -Ei ''${rockspecFilename} -e 's|lua >= 5.2|lua >= 5.1,|'
719 '';
720 meta = oa.meta // {
721 broken = luaOlder "5.1" || (luaAtLeast "5.4");
722 platforms = lib.platforms.linux;
723 };
724 });
725
726 lux-lua = final.callPackage ./lux-lua.nix { inherit lua; };
727
728 lz-n = prev.lz-n.overrideAttrs (oa: {
729 doCheck = lua.luaversion == "5.1";
730 nativeCheckInputs = [
731 final.nlua
732 final.busted
733 writableTmpDirAsHomeHook
734 ];
735 checkPhase = ''
736 runHook preCheck
737 busted --lua=nlua
738 runHook postCheck
739 '';
740 });
741
742 lze = prev.lze.overrideAttrs (oa: {
743 doCheck = lua.luaversion == "5.1";
744 nativeCheckInputs = [
745 final.nlua
746 final.busted
747 writableTmpDirAsHomeHook
748 ];
749 checkPhase = ''
750 runHook preCheck
751 busted --lua=nlua
752 runHook postCheck
753 '';
754 });
755
756 lzextras = prev.lzextras.overrideAttrs (oa: {
757 doCheck = lua.luaversion == "5.1";
758 checkInputs = [
759 final.lze
760 ];
761 nativeCheckInputs = [
762 final.nlua
763 final.busted
764 ];
765 checkPhase = ''
766 runHook preCheck
767 busted --lua=nlua
768 runHook postCheck
769 '';
770 });
771
772 neotest = prev.neotest.overrideAttrs (oa: {
773 doCheck = stdenv.hostPlatform.isLinux;
774 nativeCheckInputs = oa.nativeCheckInputs ++ [
775 final.nlua
776 final.busted
777 neovim-unwrapped
778 writableTmpDirAsHomeHook
779 ];
780
781 checkPhase = ''
782 runHook preCheck
783 export LUA_PATH="./lua/?.lua;./lua/?/init.lua;$LUA_PATH"
784 nvim --headless -i NONE \
785 --cmd "set rtp+=${vimPlugins.plenary-nvim}" \
786 -c "PlenaryBustedDirectory tests/ {sequential = true}"
787
788 runHook postCheck
789 '';
790 });
791
792 haskell-tools-nvim = prev.haskell-tools-nvim.overrideAttrs (oa: {
793 doCheck = lua.luaversion == "5.1";
794 nativeCheckInputs = [
795 final.nlua
796 final.busted
797 writableTmpDirAsHomeHook
798 ];
799 checkPhase = ''
800 runHook preCheck
801 busted --lua=nlua
802 runHook postCheck
803 '';
804 });
805
806 neorg = prev.neorg.overrideAttrs (oa: {
807 # Relax dependencies
808 postConfigure = ''
809 substituteInPlace ''${rockspecFilename} \
810 --replace-fail "'nvim-nio ~> 1.7'," "'nvim-nio >= 1.7'," \
811 --replace-fail "'plenary.nvim == 0.1.4'," "'plenary.nvim'," \
812 --replace-fail "'nui.nvim == 0.3.0'," "'nui.nvim',"
813 '';
814 });
815
816 nvim-nio = prev.nvim-nio.overrideAttrs (oa: {
817 doCheck = lua.luaversion == "5.1";
818 nativeCheckInputs = [
819 final.nlua
820 final.busted
821 writableTmpDirAsHomeHook
822 ];
823
824 # upstream uses PlenaryBusted which is a pain to setup
825 checkPhase = ''
826 runHook preCheck
827 busted --lua=nlua --lpath='lua/?.lua' --lpath='lua/?/init.lua' tests/
828 runHook postCheck
829 '';
830 });
831
832 plenary-nvim = prev.plenary-nvim.overrideAttrs (oa: {
833 postPatch = ''
834 sed -Ei lua/plenary/curl.lua \
835 -e 's@(command\s*=\s*")curl(")@\1${curl}/bin/curl\2@'
836 '';
837
838 # disabled for now because too flaky
839 doCheck = false;
840 # for env/find/ls
841 checkInputs = [
842 which
843 neovim-unwrapped
844 coreutils
845 findutils
846 writableTmpDirAsHomeHook
847 ];
848
849 checkPhase = ''
850 runHook preCheck
851 # remove failing tests, need internet access for instance
852 rm tests/plenary/job_spec.lua tests/plenary/scandir_spec.lua tests/plenary/curl_spec.lua
853 make test
854 runHook postCheck
855 '';
856 });
857
858 lyaml = prev.lyaml.overrideAttrs (oa: {
859 buildInputs = [
860 libyaml
861 ];
862 });
863
864 magick = prev.magick.overrideAttrs (oa: {
865 buildInputs = oa.buildInputs ++ [
866 imagemagick
867 ];
868
869 # Fix MagickWand not being found in the pkg-config search path
870 patches = [
871 ./magick.patch
872 ];
873
874 postPatch = ''
875 substituteInPlace magick/wand/lib.lua \
876 --replace @nix_wand@ ${imagemagick}/lib/libMagickWand-7.Q16HDRI${stdenv.hostPlatform.extensions.sharedLibrary}
877 '';
878
879 # Requires ffi
880 meta.broken = !isLuaJIT;
881 });
882
883 mpack = prev.mpack.overrideAttrs (drv: {
884 buildInputs = (drv.buildInputs or [ ]) ++ [ libmpack ];
885 env = {
886 # the rockspec doesn't use the makefile so you may need to export more flags
887 USE_SYSTEM_LUA = "yes";
888 USE_SYSTEM_MPACK = "yes";
889 };
890 });
891
892 nlua = prev.nlua.overrideAttrs (oa: {
893
894 # patchShebang removes the nvim in nlua's shebang so we hardcode one
895 postFixup = ''
896 sed -i -e "1 s|.*|#\!${coreutils}/bin/env -S ${neovim-unwrapped}/bin/nvim -l|" "$out/bin/nlua"
897 '';
898 dontPatchShebangs = true;
899 });
900
901 psl = prev.psl.overrideAttrs (drv: {
902 buildInputs = drv.buildInputs or [ ] ++ [ libpsl ];
903
904 luarocksConfig.variables = drv.luarocksConfig.variables // {
905 PSL_INCDIR = lib.getDev libpsl + "/include";
906 PSL_DIR = lib.getLib libpsl;
907 };
908 });
909
910 rapidjson = prev.rapidjson.overrideAttrs (oa: {
911 preBuild = ''
912 sed -i '/set(CMAKE_CXX_FLAGS/d' CMakeLists.txt
913 sed -i '/set(CMAKE_C_FLAGS/d' CMakeLists.txt
914 '';
915 });
916
917 # upstream broken, can't be generated, so moved out from the generated set
918 readline = final.callPackage (
919 {
920 buildLuarocksPackage,
921 fetchurl,
922 luaAtLeast,
923 luaOlder,
924 lua,
925 luaposix,
926 }:
927 buildLuarocksPackage ({
928 pname = "readline";
929 version = "3.2-0";
930 knownRockspec =
931 (fetchurl {
932 url = "mirror://luarocks/readline-3.2-0.rockspec";
933 sha256 = "1r0sgisxm4xd1r6i053iibxh30j7j3rcj4wwkd8rzkj8nln20z24";
934 }).outPath;
935 src = fetchurl {
936 # the rockspec url doesn't work because 'www.' is not covered by the certificate so
937 # I manually removed the 'www' prefix here
938 url = "http://pjb.com.au/comp/lua/readline-3.2.tar.gz";
939 sha256 = "1mk9algpsvyqwhnq7jlw4cgmfzj30l7n2r6ak4qxgdxgc39f48k4";
940 };
941
942 luarocksConfig.variables = rec {
943 READLINE_INCDIR = "${readline.dev}/include";
944 HISTORY_INCDIR = READLINE_INCDIR;
945 };
946 unpackCmd = ''
947 unzip "$curSrc"
948 tar xf *.tar.gz
949 '';
950
951 propagatedBuildInputs = [
952 luaposix
953 readline.out
954 ];
955
956 meta = {
957 homepage = "https://pjb.com.au/comp/lua/readline.html";
958 description = "Interface to the readline library";
959 license.fullName = "MIT/X11";
960 broken = (luaOlder "5.1") || (luaAtLeast "5.5");
961 };
962 })
963 ) { };
964
965 rocks-dev-nvim = prev.rocks-dev-nvim.overrideAttrs (oa: {
966
967 # E5113: Error while calling lua chunk [...] pl.path requires LuaFileSystem
968 doCheck = luaOlder "5.2";
969 nativeCheckInputs = [
970 final.nlua
971 final.busted
972 ];
973 checkPhase = ''
974 runHook preCheck
975 busted spec
976 runHook postCheck
977 '';
978 });
979
980 rtp-nvim = prev.rtp-nvim.overrideAttrs (oa: {
981 doCheck = lua.luaversion == "5.1";
982 nativeCheckInputs = [
983 final.nlua
984 final.busted
985 writableTmpDirAsHomeHook
986 ];
987 checkPhase = ''
988 runHook preCheck
989 busted --lua=nlua
990 runHook postCheck
991 '';
992 });
993
994 rustaceanvim = prev.rustaceanvim.overrideAttrs (oa: {
995 doCheck = lua.luaversion == "5.1";
996 nativeCheckInputs = [
997 final.nlua
998 final.busted
999 writableTmpDirAsHomeHook
1000 ];
1001 checkPhase = ''
1002 runHook preCheck
1003 busted --lua=nlua
1004 runHook postCheck
1005 '';
1006 });
1007
1008 sofa = prev.sofa.overrideAttrs (oa: {
1009 nativeBuildInputs = oa.nativeBuildInputs ++ [
1010 installShellFiles
1011 ];
1012 postInstall = lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
1013 installShellCompletion --cmd sofa \
1014 --bash <($out/bin/sofa --completion bash) \
1015 --fish <($out/bin/sofa --completion fish) \
1016 --zsh <($out/bin/sofa --completion zsh)
1017 '';
1018 });
1019
1020 sqlite = prev.sqlite.overrideAttrs (drv: {
1021 doCheck = stdenv.hostPlatform.isLinux;
1022 nativeCheckInputs = [
1023 final.plenary-nvim
1024 neovim-unwrapped
1025 writableTmpDirAsHomeHook
1026 ];
1027
1028 # the plugin loads the library from either the LIBSQLITE env
1029 # or the vim.g.sqlite_clib_path variable.
1030 postPatch = ''
1031 substituteInPlace lua/sqlite/defs.lua \
1032 --replace-fail "path = vim.g.sqlite_clib_path" 'path = vim.g.sqlite_clib_path or "${sqlite.out}/lib/libsqlite3${stdenv.hostPlatform.extensions.sharedLibrary}"'
1033 '';
1034
1035 # we override 'luarocks test' because otherwise neovim doesn't find/load the plenary plugin
1036 checkPhase = ''
1037 nvim --headless -i NONE \
1038 -u test/minimal_init.vim --cmd "set rtp+=${vimPlugins.plenary-nvim}" \
1039 -c "PlenaryBustedDirectory test/auto/ { sequential = true, minimal_init = './test/minimal_init.vim' }"
1040 '';
1041
1042 });
1043
1044 std-_debug = prev.std-_debug.overrideAttrs (oa: {
1045 # run make to generate lib/std/_debug/version.lua
1046 preConfigure = ''
1047 make all
1048 '';
1049 });
1050
1051 std-normalize = prev.std-normalize.overrideAttrs (oa: {
1052 # run make to generate lib/std/_debug/version.lua
1053 preConfigure = ''
1054 make all
1055 '';
1056 });
1057
1058 tiktoken_core = prev.tiktoken_core.overrideAttrs (oa: {
1059 cargoDeps = rustPlatform.fetchCargoVendor {
1060 src = oa.src;
1061 hash = "sha256-egmb4BTbORpTpVO50IcqbZU1Y0hioXLMkxxUAo05TIA=";
1062 };
1063 nativeBuildInputs = oa.nativeBuildInputs ++ [
1064 cargo
1065 rustPlatform.cargoSetupHook
1066 ];
1067 });
1068
1069 tl = prev.tl.overrideAttrs (oa: {
1070 preConfigure = ''
1071 rm luarocks.lock
1072 '';
1073 meta = oa.meta // {
1074 mainProgram = "tl";
1075 };
1076 });
1077
1078 toml-edit = prev.toml-edit.overrideAttrs (oa: {
1079
1080 cargoDeps = rustPlatform.fetchCargoVendor {
1081 src = oa.src;
1082 hash = "sha256-ow0zefFFrU91Q2PJww2jtd6nqUjwXUtfQzjkzl/AXuo=";
1083 };
1084
1085 NIX_LDFLAGS = lib.optionalString stdenv.hostPlatform.isDarwin (
1086 if lua.pkgs.isLuaJIT then "-lluajit-${lua.luaversion}" else "-llua"
1087 );
1088
1089 nativeBuildInputs = oa.nativeBuildInputs ++ [
1090 cargo
1091 rustPlatform.cargoSetupHook
1092 lua.pkgs.luarocks-build-rust-mlua
1093 ];
1094
1095 });
1096
1097 tree-sitter-http = prev.tree-sitter-http.overrideAttrs (oa: {
1098 propagatedBuildInputs =
1099 let
1100 # HACK: luarocks-nix puts rockspec build dependencies in the nativeBuildInputs,
1101 # but that doesn't seem to work
1102 lua = lib.head oa.propagatedBuildInputs;
1103 in
1104 oa.propagatedBuildInputs
1105 ++ [
1106 lua.pkgs.luarocks-build-treesitter-parser
1107 tree-sitter
1108 ];
1109
1110 nativeBuildInputs = oa.nativeBuildInputs or [ ] ++ [
1111 writableTmpDirAsHomeHook
1112 ];
1113 });
1114
1115 tree-sitter-norg = prev.tree-sitter-norg.overrideAttrs (oa: {
1116 propagatedBuildInputs =
1117 let
1118 # HACK: luarocks-nix puts rockspec build dependencies in the nativeBuildInputs,
1119 # but that doesn't seem to work
1120 lua = lib.head oa.propagatedBuildInputs;
1121 in
1122 oa.propagatedBuildInputs
1123 ++ [
1124 lua.pkgs.luarocks-build-treesitter-parser-cpp
1125 ];
1126 });
1127
1128 orgmode = prev.orgmode.overrideAttrs (oa: {
1129 # Patch in tree-sitter-orgmode dependency
1130 postPatch = ''
1131 substituteInPlace lua/orgmode/config/init.lua \
1132 --replace-fail \
1133 "require('orgmode.utils.treesitter.install').install()" \
1134 "pcall(function() vim.treesitter.language.add('org', { path = '${final.tree-sitter-orgmode}/lib/lua/${final.tree-sitter-orgmode.lua.luaversion}/parser/org.so'}) end)" \
1135 --replace-fail \
1136 "require('orgmode.utils.treesitter.install').reinstall()" \
1137 "pcall(function() vim.treesitter.language.add('org', { path = '${final.tree-sitter-orgmode}/lib/lua/${final.tree-sitter-orgmode.lua.luaversion}/parser/org.so'}) end)"
1138 '';
1139 });
1140
1141 tree-sitter-orgmode = prev.tree-sitter-orgmode.overrideAttrs (oa: {
1142 propagatedBuildInputs =
1143 let
1144 # HACK: luarocks-nix puts rockspec build dependencies in the nativeBuildInputs,
1145 # but that doesn't seem to work
1146 lua = lib.head oa.propagatedBuildInputs;
1147 in
1148 oa.propagatedBuildInputs
1149 ++ [
1150 lua.pkgs.luarocks-build-treesitter-parser
1151 tree-sitter
1152 ];
1153 nativeBuildInputs = oa.nativeBuildInputs or [ ] ++ [
1154 writableTmpDirAsHomeHook
1155 ];
1156 });
1157
1158 vstruct = prev.vstruct.overrideAttrs (_: {
1159 meta.broken = (luaOlder "5.1" || luaAtLeast "5.4");
1160 });
1161
1162 vusted = prev.vusted.overrideAttrs (_: {
1163 # make sure vusted_entry.vim doesn't get wrapped
1164 postInstall = ''
1165 chmod -x $out/bin/vusted_entry.vim
1166 '';
1167 });
1168
1169 # aliases
1170 cjson = prev.lua-cjson;
1171}