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