anvil-editor: init at 0.4
[NixPkgs.git] / pkgs / development / lua-modules / overrides.nix
blob1ed1d6719e38f5f35f2da99ded2bab28308c7d83
1 # do not add pkgs, it messes up splicing
2 { stdenv
3 , cargo
4 , cmake
6 # plenary utilities
7 , which
8 , findutils
9 , clang
10 , coreutils
11 , curl
12 , cyrus_sasl
13 , dbus
14 , expat
15 , fetchFromGitHub
16 , fetchpatch
17 , fetchurl
18 , fixDarwinDylibNames
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 , libuuid
34 , libuv
35 , libxcrypt
36 , libyaml
37 , luajitPackages
38 , lua-language-server
39 , mariadb
40 , magic-enum
41 , mpfr
42 , neovim-unwrapped
43 , openldap
44 , openssl
45 , pcre
46 , pkg-config
47 , postgresql
48 , readline
49 , rustPlatform
50 , sol2
51 , sqlite
52 , tomlplusplus
53 , tree-sitter
54 , unbound
55 , vimPlugins
56 , vimUtils
57 , yajl
58 , zip
59 , unzip
60 , zlib
61 , zziplib
64 final: prev:
65 let
66   inherit (prev) luaOlder luaAtLeast lua isLuaJIT isLua51;
69   argparse = prev.argparse.overrideAttrs(oa: {
71     doCheck = true;
72     checkInputs = [ final.busted ];
74     checkPhase = ''
75       runHook preCheck
76       export LUA_PATH="src/?.lua;$LUA_PATH"
77       busted spec/
78       runHook postCheck
79     '';
80   });
81   ##########################################3
82   #### manual fixes for generated packages
83   ##########################################3
84   bit32 = prev.bit32.overrideAttrs (oa: {
85     # Small patch in order to no longer redefine a Lua 5.2 function that Luajit
86     # 2.1 also provides, see https://github.com/LuaJIT/LuaJIT/issues/325 for
87     # more
88     patches = [
89       ./bit32.patch
90     ];
91     meta.broken = luaOlder "5.1" || luaAtLeast "5.4";
92   });
94   busted = prev.busted.overrideAttrs (oa: {
95     nativeBuildInputs = oa.nativeBuildInputs ++ [
96       installShellFiles
97     ];
98     postConfigure = ''
99       substituteInPlace ''${rockspecFilename} \
100         --replace-fail "'lua_cliargs = 3.0'," "'lua_cliargs >= 3.0-1',"
101     '';
102     postInstall = ''
103       installShellCompletion --cmd busted \
104         --zsh completions/zsh/_busted \
105         --bash completions/bash/busted.bash
106     '';
107   });
109   cqueues = prev.cqueues.overrideAttrs (oa: rec {
110     # Parse out a version number without the Lua version inserted
111     version = let
112       version' = prev.cqueues.version;
113       rel = lib.splitVersion version';
114       date = lib.head rel;
115       rev = lib.last (lib.splitString "-" (lib.last rel));
116     in
117     "${date}-${rev}";
119     meta.broken = luaOlder "5.1" || luaAtLeast "5.4";
121     nativeBuildInputs = oa.nativeBuildInputs ++ [
122       gnum4
123     ];
125     externalDeps = [
126       { name = "CRYPTO"; dep = openssl; }
127       { name = "OPENSSL"; dep = openssl; }
128     ];
130     # Upstream rockspec is pointlessly broken into separate rockspecs, per Lua
131     # version, which doesn't work well for us, so modify it
132     postConfigure = let inherit (prev.cqueues) pname; in
133       ''
134         # 'all' target auto-detects correct Lua version, which is fine for us as
135         # we only have the right one available :)
136         sed -Ei ''${rockspecFilename} \
137           -e 's|lua == 5.[[:digit:]]|lua >= 5.1, <= 5.3|' \
138           -e 's|build_target = "[^"]+"|build_target = "all"|' \
139           -e 's|version = "[^"]+"|version = "${version}"|'
140         specDir=$(dirname ''${rockspecFilename})
141         cp ''${rockspecFilename} "$specDir/${pname}-${version}.rockspec"
142         rockspecFilename="$specDir/${pname}-${version}.rockspec"
143       '';
144   });
146   # Until https://github.com/swarn/fzy-lua/pull/8 is merged,
147   # we have to invoke busted manually
148   fzy = prev.fzy.overrideAttrs(oa: {
149     doCheck = true;
150     nativeCheckInputs = [ final.busted ];
151     checkPhase = ''
152       busted
153     '';
154   });
156   http = prev.http.overrideAttrs (oa: {
157     patches = [
158       (fetchpatch {
159         name = "invalid-state-progression.patch";
160         url = "https://github.com/daurnimator/lua-http/commit/cb7b59474a.diff";
161         sha256 = "1vmx039n3nqfx50faqhs3wgiw28ws416rhw6vh6srmh9i826dac7";
162       })
163     ];
164     /* TODO: separate docs derivation? (pandoc is heavy)
165       nativeBuildInputs = [ pandoc ];
166       makeFlags = [ "-C doc" "lua-http.html" "lua-http.3" ];
167     */
168   });
170   image-nvim = prev.image-nvim.overrideAttrs (oa: {
171     propagatedBuildInputs = [
172       lua
173       luajitPackages.magick
174     ];
175   });
177   ldbus = prev.ldbus.overrideAttrs (oa: {
178     luarocksConfig = oa.luarocksConfig // {
179       variables = {
180         DBUS_DIR = "${dbus.lib}";
181         DBUS_ARCH_INCDIR = "${dbus.lib}/lib/dbus-1.0/include";
182         DBUS_INCDIR = "${dbus.dev}/include/dbus-1.0";
183       };
184     };
185     buildInputs = [
186       dbus
187     ];
188   });
190   ljsyscall = prev.ljsyscall.overrideAttrs (oa: rec {
191     version = "unstable-20180515";
192     # package hasn't seen any release for a long time
193     src = fetchFromGitHub {
194       owner = "justincormack";
195       repo = "ljsyscall";
196       rev = "e587f8c55aad3955dddab3a4fa6c1968037b5c6e";
197       sha256 = "06v52agqyziwnbp2my3r7liv245ddmb217zmyqakh0ldjdsr8lz4";
198     };
199     knownRockspec = "rockspec/ljsyscall-scm-1.rockspec";
200     # actually library works fine with lua 5.2
201     preConfigure = ''
202       sed -i 's/lua == 5.1/lua >= 5.1, < 5.3/' ${knownRockspec}
203     '';
204     meta.broken = luaOlder "5.1" || luaAtLeast "5.3";
206     propagatedBuildInputs = oa.propagatedBuildInputs ++ lib.optional (!isLuaJIT) final.luaffi;
207   });
209   lgi = prev.lgi.overrideAttrs (oa: {
210     nativeBuildInputs = oa.nativeBuildInputs ++ [
211       pkg-config
212     ];
213     buildInputs = [
214       glib
215       gobject-introspection
216     ];
217     patches = [
218       (fetchpatch {
219         name = "lgi-find-cairo-through-typelib.patch";
220         url = "https://github.com/psychon/lgi/commit/46a163d9925e7877faf8a4f73996a20d7cf9202a.patch";
221         sha256 = "0gfvvbri9kyzhvq3bvdbj2l6mwvlz040dk4mrd5m9gz79f7w109c";
222       })
223     ];
225     # https://github.com/lgi-devs/lgi/pull/300
226     postPatch = ''
227       substituteInPlace lgi/Makefile tests/Makefile \
228         --replace 'PKG_CONFIG =' 'PKG_CONFIG ?='
229     '';
231     # there is only a rockspec.in in the repo, the actual rockspec must be generated
232     preConfigure = ''
233       make rock
234     '';
236     # Lua 5.4 support is experimental at the moment, see
237     # https://github.com/lgi-devs/lgi/pull/249
238     meta.broken = luaOlder "5.1" || luaAtLeast "5.4";
239   });
241   llscheck = prev.llscheck.overrideAttrs (oa: {
242     propagatedBuildInputs = oa.propagatedBuildInputs ++ [ lua-language-server ];
243   });
245   lmathx = prev.luaLib.overrideLuarocks prev.lmathx (drv:
246     if luaAtLeast "5.1" && luaOlder "5.2" then {
247       version = "20120430.51-1";
248       knownRockspec = (fetchurl {
249         url = "mirror://luarocks/lmathx-20120430.51-1.rockspec";
250         sha256 = "148vbv2g3z5si2db7rqg5bdily7m4sjyh9w6r3jnx3csvfaxyhp0";
251       }).outPath;
252       src = fetchurl {
253         url = "https://web.tecgraf.puc-rio.br/~lhf/ftp/lua/5.1/lmathx.tar.gz";
254         sha256 = "0sa553d0zlxhvpsmr4r7d841f16yq4wr3fg7i07ibxkz6yzxax51";
255       };
256     } else
257       if luaAtLeast "5.2" && luaOlder "5.3" then {
258         version = "20120430.52-1";
259         knownRockspec = (fetchurl {
260           url = "mirror://luarocks/lmathx-20120430.52-1.rockspec";
261           sha256 = "14rd625sipakm72wg6xqsbbglaxyjba9nsajsfyvhg0sz8qjgdya";
262         }).outPath;
263         src = fetchurl {
264           url = "http://www.tecgraf.puc-rio.br/~lhf/ftp/lua/5.2/lmathx.tar.gz";
265           sha256 = "19dwa4z266l2njgi6fbq9rak4rmx2fsx1s0p9sl166ar3mnrdwz5";
266         };
267       } else
268         {
269           disabled = luaOlder "5.1" || luaAtLeast "5.5";
270           # works fine with 5.4 as well
271           postConfigure = ''
272             substituteInPlace ''${rockspecFilename} \
273               --replace 'lua ~> 5.3' 'lua >= 5.3, < 5.5'
274           '';
275         });
277   lmpfrlib = prev.lmpfrlib.overrideAttrs (oa: {
278     externalDeps = [
279       { name = "GMP"; dep = gmp; }
280       { name = "MPFR"; dep = mpfr; }
281     ];
282     unpackPhase = ''
283       cp $src $(stripHash $src)
284     '';
285   });
287   lrexlib-gnu = prev.lrexlib-gnu.overrideAttrs (oa: {
288     buildInputs = oa.buildInputs ++ [
289       gnulib
290     ];
291   });
293   lrexlib-pcre = prev.lrexlib-pcre.overrideAttrs (oa: {
294     externalDeps = [
295       { name = "PCRE"; dep = pcre; }
296     ];
297   });
299   lrexlib-posix = prev.lrexlib-posix.overrideAttrs (oa: {
300     buildInputs = oa.buildInputs ++ [
301       glibc.dev
302     ];
303   });
305   lua-curl = prev.lua-curl.overrideAttrs (oa: {
306     buildInputs = oa.buildInputs ++ [
307       curl.dev
308     ];
309   });
311   lua-iconv = prev.lua-iconv.overrideAttrs (oa: {
312     buildInputs = oa.buildInputs ++ [
313       libiconv
314     ];
315   });
317   lua-lsp = prev.lua-lsp.overrideAttrs (oa: {
318     # until Alloyed/lua-lsp#28
319     postConfigure = ''
320       substituteInPlace ''${rockspecFilename} \
321         --replace '"dkjson ~> 2.5",' '"dkjson >= 2.5",'
322     '';
323   });
325   lua-resty-jwt = prev.lua-resty-jwt.overrideAttrs(oa: {
326     src = fetchFromGitHub {
327       owner = "cdbattags";
328       repo = "lua-resty-jwt";
329       rev = "v0.2.3";
330       hash = "sha256-5lnr0ka6ijfujiRjqwCPb6jzItXx45FIN8CvhR/KiB8=";
331       fetchSubmodules = true;
332     };
333   });
335   lua-zlib = prev.lua-zlib.overrideAttrs (oa: {
336     buildInputs = oa.buildInputs ++ [
337       zlib.dev
338     ];
339     meta = oa.meta // { broken = luaOlder "5.1" || luaAtLeast "5.4"; };
340   });
342   luadbi-mysql = prev.luadbi-mysql.overrideAttrs (oa: {
344     luarocksConfig = lib.recursiveUpdate oa.luarocksConfig {
345       variables = {
346         # Can't just be /include and /lib, unfortunately needs the trailing 'mysql'
347         MYSQL_INCDIR = "${libmysqlclient.dev}/include/mysql";
348         MYSQL_LIBDIR = "${libmysqlclient}/lib/mysql";
349       };
350     };
351     buildInputs = oa.buildInputs ++ [
352       mariadb.client
353       libmysqlclient
354     ];
355   });
357   luadbi-postgresql = prev.luadbi-postgresql.overrideAttrs (oa: {
358     buildInputs = oa.buildInputs ++ [
359       (lib.getDev postgresql)
360     ];
361   });
363   luadbi-sqlite3 = prev.luadbi-sqlite3.overrideAttrs (oa: {
364     externalDeps = [
365       { name = "SQLITE"; dep = sqlite; }
366     ];
367   });
369   luaevent = prev.luaevent.overrideAttrs (oa: {
370     propagatedBuildInputs = oa.propagatedBuildInputs ++ [
371       final.luasocket
372     ];
373     externalDeps = [
374       { name = "EVENT"; dep = libevent; }
375     ];
376     meta.broken = luaOlder "5.1" || luaAtLeast "5.4";
377   });
379   luaexpat = prev.luaexpat.overrideAttrs (_: {
380     externalDeps = [
381       { name = "EXPAT"; dep = expat; }
382     ];
383   });
385   # TODO Somehow automatically amend buildInputs for things that need luaffi
386   # but are in luajitPackages?
387   luaffi = prev.luaffi.overrideAttrs (oa: {
388     # The packaged .src.rock version is pretty old, and doesn't work with Lua 5.3
389     src = fetchFromGitHub {
390       owner = "facebook";
391       repo = "luaffifb";
392       rev = "532c757e51c86f546a85730b71c9fef15ffa633d";
393       sha256 = "1nwx6sh56zfq99rcs7sph0296jf6a9z72mxknn0ysw9fd7m1r8ig";
394     };
395     knownRockspec = with prev.luaffi; "${pname}-${version}.rockspec";
396     meta.broken = luaOlder "5.1" || luaAtLeast "5.4" || isLuaJIT;
397   });
399   lualdap = prev.lualdap.overrideAttrs (_: {
400     externalDeps = [
401       { name = "LDAP"; dep = openldap; }
402     ];
403   });
405   luaossl = prev.luaossl.overrideAttrs (_: {
406     externalDeps = [
407       { name = "CRYPTO"; dep = openssl; }
408       { name = "OPENSSL"; dep = openssl; }
409     ];
410   });
412   luaposix = prev.luaposix.overrideAttrs (_: {
413     externalDeps = [
414       { name = "CRYPT"; dep = libxcrypt; }
415     ];
416   });
418   luaprompt = prev.luaprompt.overrideAttrs (oa: {
419     externalDeps = [
420       { name = "READLINE"; dep = readline; }
421       { name = "HISTORY"; dep = readline; }
422     ];
424     nativeBuildInputs = oa.nativeBuildInputs ++ [ installShellFiles ];
426     postInstall = ''
427       installManPage luap.1
428     '';
429   });
431   # As a nix user, use this derivation instead of "luarocks_bootstrap"
432   luarocks = prev.luarocks.overrideAttrs (oa: {
434     nativeBuildInputs = oa.nativeBuildInputs ++ [ installShellFiles lua unzip ];
435     # cmake is just to compile packages with "cmake" buildType, not luarocks itself
436     dontUseCmakeConfigure = true;
438     propagatedBuildInputs = [ zip unzip cmake ];
440     postInstall = lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
441       installShellCompletion --cmd luarocks \
442         --bash <($out/bin/luarocks completion bash) \
443         --fish <($out/bin/luarocks completion fish) \
444         --zsh <($out/bin/luarocks completion zsh)
446       installShellCompletion --cmd luarocks-admin \
447         --bash <($out/bin/luarocks-admin completion bash) \
448         --fish <($out/bin/luarocks-admin completion fish) \
449         --zsh <($out/bin/luarocks-admin completion zsh)
450     '';
452     meta = oa.meta // {
453       mainProgram = "luarocks";
454     };
456   });
458   luasec = prev.luasec.overrideAttrs (oa: {
459     externalDeps = [
460       { name = "OPENSSL"; dep = openssl; }
461     ];
462   });
464   luasql-sqlite3 = prev.luasql-sqlite3.overrideAttrs (oa: {
465     externalDeps = [
466       { name = "SQLITE"; dep = sqlite; }
467     ];
468   });
470   luasystem = prev.luasystem.overrideAttrs (oa: lib.optionalAttrs stdenv.hostPlatform.isLinux {
471     buildInputs = [ glibc.out ];
472   });
474   luazip = prev.luazip.overrideAttrs (oa: {
475     buildInputs = oa.buildInputs ++ [
476       zziplib
477     ];
478   });
480   # lua-resty-session =  prev.lua-resty-session.overrideAttrs (oa: {
481   #   # lua_pack and lua-ffi-zlib are unpackaged, causing this package to not evaluate
482   #   meta.broken = true;
483   # });
485   lua-yajl =  prev.lua-yajl.overrideAttrs (oa: {
486     buildInputs = oa.buildInputs ++ [
487       yajl
488     ];
489   });
491   luaunbound = prev.luaunbound.overrideAttrs (oa: {
492     externalDeps = [
493       { name = "libunbound"; dep = unbound; }
494     ];
495   });
497   lua-subprocess = prev.lua-subprocess.overrideAttrs (oa: {
498     meta.broken = luaOlder "5.1" || luaAtLeast "5.4";
499   });
501   lua-rtoml = prev.lua-rtoml.overrideAttrs (oa: {
503     cargoDeps = rustPlatform.fetchCargoTarball {
504       src = oa.src;
505       hash = "sha256-EcP4eYsuOVeEol+kMqzsVHd8F2KoBdLzf6K0KsYToUY=";
506     };
508     propagatedBuildInputs = oa.propagatedBuildInputs ++ [ cargo rustPlatform.cargoSetupHook ];
510     # ld: symbol(s) not found for architecture arm64
511     # clang-16: error: linker command failed with exit code 1 (use -v to see invocation)
512     meta.broken = stdenv.hostPlatform.isDarwin;
513   });
515   lush-nvim = prev.lush-nvim.overrideAttrs (drv: {
516     doCheck = false;
517   });
519   luuid = prev.luuid.overrideAttrs (oa: {
520     externalDeps = [
521       { name = "LIBUUID"; dep = libuuid; }
522     ];
523     # Trivial patch to make it work in both 5.1 and 5.2.  Basically just the
524     # tiny diff between the two upstream versions placed behind an #if.
525     # Upstreams:
526     # 5.1: http://webserver2.tecgraf.puc-rio.br/~lhf/ftp/lua/5.1/luuid.tar.gz
527     # 5.2: http://webserver2.tecgraf.puc-rio.br/~lhf/ftp/lua/5.2/luuid.tar.gz
528     patchFlags = [ "-p2" ];
529     patches = [
530       ./luuid.patch
531     ];
532     postConfigure =  ''
533       sed -Ei ''${rockspecFilename} -e 's|lua >= 5.2|lua >= 5.1,|'
534     '';
535     meta = oa.meta // {
536       broken = luaOlder "5.1" || (luaAtLeast "5.4");
537       platforms = lib.platforms.linux;
538     };
539   });
541   lz-n  = prev.lz-n.overrideAttrs(oa: {
542     doCheck = lua.luaversion == "5.1";
543     nativeCheckInputs = [ final.nlua final.busted ];
544     checkPhase = ''
545       runHook preCheck
546       export HOME=$(mktemp -d)
547       busted --lua=nlua
548       runHook postCheck
549       '';
550   });
552   lze  = prev.lze.overrideAttrs(oa: {
553     doCheck = lua.luaversion == "5.1";
554     nativeCheckInputs = [ final.nlua final.busted ];
555     checkPhase = ''
556       runHook preCheck
557       export HOME=$(mktemp -d)
558       busted --lua=nlua
559       runHook postCheck
560     '';
561   });
563   neotest  = prev.neotest.overrideAttrs(oa: {
564     doCheck = stdenv.isLinux;
565     nativeCheckInputs = oa.nativeCheckInputs ++ [
566       final.nlua final.busted neovim-unwrapped
567     ];
569     # stick to neovim's lua version else loading shared libraries fail
570     meta = oa.meta // { broken = !isLua51; };
572     checkPhase = ''
573       runHook preCheck
574       export HOME=$(mktemp -d)
575       export LUA_PATH="./lua/?.lua;./lua/?/init.lua;$LUA_PATH"
576       nvim --headless -i NONE \
577         --cmd "set rtp+=${vimPlugins.plenary-nvim}" \
578         -c "PlenaryBustedDirectory tests/ {sequential = true}"
580       runHook postCheck
581       '';
582   });
584   haskell-tools-nvim  = prev.haskell-tools-nvim.overrideAttrs(oa: {
585     doCheck = lua.luaversion == "5.1";
586     nativeCheckInputs = [ final.nlua final.busted ];
587     checkPhase = ''
588       runHook preCheck
589       export HOME=$(mktemp -d)
590       busted --lua=nlua
591       runHook postCheck
592     '';
593   });
595   neorg = prev.neorg.overrideAttrs (oa: {
596     postConfigure = ''
597       substituteInPlace ''${rockspecFilename} \
598         --replace-fail "'nvim-nio ~> 1.7'," "'nvim-nio >= 1.7'," \
599         --replace-fail "'plenary.nvim == 0.1.4'," "'plenary.nvim',"
600     '';
601   });
603   plenary-nvim = prev.plenary-nvim.overrideAttrs (oa: {
604     postPatch = ''
605       sed -Ei lua/plenary/curl.lua \
606           -e 's@(command\s*=\s*")curl(")@\1${curl}/bin/curl\2@'
607     '';
609     # disabled for now because too flaky
610     doCheck = false;
611     # for env/find/ls
612     checkInputs = [
613       which
614       neovim-unwrapped
615       coreutils
616       findutils
617     ];
619     checkPhase = ''
620       runHook preCheck
621       # remove failing tests, need internet access for instance
622       rm tests/plenary/job_spec.lua tests/plenary/scandir_spec.lua tests/plenary/curl_spec.lua
623       export HOME="$TMPDIR"
624       make test
625       runHook postCheck
626     '';
627   });
629   # as advised in https://github.com/luarocks/luarocks/issues/1402#issuecomment-1080616570
630   # we shouldn't use luarocks machinery to build complex cmake components
631   libluv = stdenv.mkDerivation {
633     pname = "libluv";
634     inherit (prev.luv) version meta src;
636     cmakeFlags = [
637       "-DBUILD_SHARED_LIBS=ON"
638       "-DBUILD_MODULE=OFF"
639       "-DWITH_SHARED_LIBUV=ON"
640       "-DLUA_BUILD_TYPE=System"
641       "-DWITH_LUA_ENGINE=${if isLuaJIT then "LuaJit" else "Lua"}"
642     ];
644     # to make sure we dont use bundled deps
645     postUnpack = ''
646       rm -rf deps/lua deps/libuv
647     '';
649     buildInputs = [ libuv final.lua ];
651     nativeBuildInputs = [ pkg-config cmake ]
652       ++ lib.optionals stdenv.hostPlatform.isDarwin [ fixDarwinDylibNames ];
653   };
655   luv = prev.luv.overrideAttrs (oa: {
657     nativeBuildInputs = oa.nativeBuildInputs ++ [ pkg-config ];
658     buildInputs = [ libuv ];
660     # Use system libuv instead of building local and statically linking
661     luarocksConfig = lib.recursiveUpdate oa.luarocksConfig {
662       variables = { WITH_SHARED_LIBUV = "ON"; };
663     };
665     # we unset the LUA_PATH since the hook erases the interpreter defaults (To fix)
666     # tests is not run since they are not part of the tarball anymore
667     preCheck = ''
668       unset LUA_PATH
669       rm tests/test-{dns,thread}.lua
670     '';
671   });
673   lyaml = prev.lyaml.overrideAttrs (oa: {
674     buildInputs = [
675       libyaml
676     ];
677   });
679   magick = prev.magick.overrideAttrs (oa: {
680     buildInputs = oa.buildInputs ++ [
681       imagemagick
682     ];
684     # Fix MagickWand not being found in the pkg-config search path
685     patches = [
686       ./magick.patch
687     ];
689     postPatch = ''
690       substituteInPlace magick/wand/lib.lua \
691         --replace @nix_wand@ ${imagemagick}/lib/libMagickWand-7.Q16HDRI${stdenv.hostPlatform.extensions.sharedLibrary}
692     '';
694     # Requires ffi
695     meta.broken = !isLuaJIT;
696   });
698   mpack = prev.mpack.overrideAttrs (drv: {
699     buildInputs = (drv.buildInputs or []) ++ [ libmpack ];
700     env = {
701       # the rockspec doesn't use the makefile so you may need to export more flags
702       USE_SYSTEM_LUA = "yes";
703       USE_SYSTEM_MPACK = "yes";
704     };
705   });
707   nlua = prev.nlua.overrideAttrs(oa: {
709     # patchShebang removes the nvim in nlua's shebang so we hardcode one
710     postFixup = ''
711       sed -i -e "1 s|.*|#\!${coreutils}/bin/env -S ${neovim-unwrapped}/bin/nvim -l|" "$out/bin/nlua"
712       '';
713     dontPatchShebangs = true;
714   });
716   psl = prev.psl.overrideAttrs (drv: {
717     buildInputs = drv.buildInputs or [ ] ++ [ libpsl ];
719     luarocksConfig.variables = drv.luarocksConfig.variables // {
720       PSL_INCDIR = lib.getDev libpsl + "/include";
721       PSL_DIR = lib.getLib libpsl;
722     };
723   });
725   rapidjson = prev.rapidjson.overrideAttrs (oa: {
726     preBuild = ''
727       sed -i '/set(CMAKE_CXX_FLAGS/d' CMakeLists.txt
728       sed -i '/set(CMAKE_C_FLAGS/d' CMakeLists.txt
729     '';
730   });
732   # upstream broken, can't be generated, so moved out from the generated set
733   readline = final.callPackage({ buildLuarocksPackage, fetchurl, luaAtLeast, luaOlder, lua, luaposix }:
734   buildLuarocksPackage ({
735     pname = "readline";
736     version = "3.2-0";
737     knownRockspec = (fetchurl {
738       url    = "mirror://luarocks/readline-3.2-0.rockspec";
739       sha256 = "1r0sgisxm4xd1r6i053iibxh30j7j3rcj4wwkd8rzkj8nln20z24";
740     }).outPath;
741     src = fetchurl {
742       # the rockspec url doesn't work because 'www.' is not covered by the certificate so
743       # I manually removed the 'www' prefix here
744       url    = "http://pjb.com.au/comp/lua/readline-3.2.tar.gz";
745       sha256 = "1mk9algpsvyqwhnq7jlw4cgmfzj30l7n2r6ak4qxgdxgc39f48k4";
746     };
748     luarocksConfig.variables = rec {
749       READLINE_INCDIR = "${readline.dev}/include";
750       HISTORY_INCDIR = READLINE_INCDIR;
751     };
752     unpackCmd = ''
753       unzip "$curSrc"
754       tar xf *.tar.gz
755     '';
757     propagatedBuildInputs = [
758       luaposix
759       readline.out
760     ];
762     meta = {
763       homepage = "http://pjb.com.au/comp/lua/readline.html";
764       description = "Interface to the readline library";
765       license.fullName = "MIT/X11";
766       broken = (luaOlder "5.1") || (luaAtLeast "5.5");
767     };
768   })) {};
770   rtp-nvim  = prev.rtp-nvim.overrideAttrs(oa: {
771     doCheck = lua.luaversion == "5.1";
772     nativeCheckInputs = [ final.nlua final.busted ];
773     checkPhase = ''
774       runHook preCheck
775       export HOME=$(mktemp -d)
776       busted --lua=nlua
777       runHook postCheck
778       '';
779   });
781   rustaceanvim  = prev.rustaceanvim.overrideAttrs(oa: {
782     doCheck = lua.luaversion == "5.1";
783     nativeCheckInputs = [ final.nlua final.busted ];
784     checkPhase = ''
785       runHook preCheck
786       export HOME=$(mktemp -d)
787       busted --lua=nlua
788       runHook postCheck
789       '';
790   });
792   sqlite = prev.sqlite.overrideAttrs (drv: {
793     doCheck = stdenv.hostPlatform.isLinux;
794     nativeCheckInputs = [ final.plenary-nvim neovim-unwrapped ];
796     # the plugin loads the library from either the LIBSQLITE env
797     # or the vim.g.sqlite_clib_path variable.
798     postPatch = ''
799       substituteInPlace lua/sqlite/defs.lua \
800         --replace-fail "path = vim.g.sqlite_clib_path" 'path = vim.g.sqlite_clib_path or  "${sqlite.out}/lib/libsqlite3${stdenv.hostPlatform.extensions.sharedLibrary}"'
801     '';
803     # we override 'luarocks test' because otherwise neovim doesn't find/load the plenary plugin
804     checkPhase = ''
805       export HOME="$TMPDIR";
807       nvim --headless -i NONE \
808         -u test/minimal_init.vim --cmd "set rtp+=${vimPlugins.plenary-nvim}" \
809         -c "PlenaryBustedDirectory test/auto/ { sequential = true, minimal_init = './test/minimal_init.vim' }"
810     '';
812   });
814   std-_debug = prev.std-_debug.overrideAttrs (oa: {
815     # run make to generate lib/std/_debug/version.lua
816     preConfigure = ''
817       make all
818     '';
819   });
821   std-normalize = prev.std-normalize.overrideAttrs (oa: {
822     # run make to generate lib/std/_debug/version.lua
823     preConfigure = ''
824       make all
825     '';
826   });
828   tiktoken_core = prev.tiktoken_core.overrideAttrs (oa: {
829     cargoDeps = rustPlatform.fetchCargoTarball {
830       src = oa.src;
831       hash = "sha256-pKqG8aiV8BvvDO6RE6J3HEA/S4E4QunbO4WBpV5jUYk=";
832     };
833     nativeBuildInputs = oa.nativeBuildInputs ++ [ cargo rustPlatform.cargoSetupHook ];
834   });
836   toml-edit = prev.toml-edit.overrideAttrs (oa: {
838     cargoDeps = rustPlatform.fetchCargoTarball {
839       src = oa.src;
840       hash = "sha256-lguGj8fDqztrvqvEYVcJLmiuxPDaCpXU8aztInKjF+E=";
841     };
843     NIX_LDFLAGS = lib.optionalString stdenv.hostPlatform.isDarwin
844       (if lua.pkgs.isLuaJIT then "-lluajit-${lua.luaversion}" else "-llua");
846     nativeBuildInputs = oa.nativeBuildInputs ++ [
847       cargo
848       rustPlatform.cargoSetupHook
849       lua.pkgs.luarocks-build-rust-mlua
850     ];
852   });
854   tree-sitter-norg = prev.tree-sitter-norg.overrideAttrs (oa: {
855     propagatedBuildInputs = let
856       # HACK: luarocks-nix puts rockspec build dependencies in the nativeBuildInputs,
857       # but that doesn't seem to work
858       lua = lib.head oa.propagatedBuildInputs;
859     in oa.propagatedBuildInputs ++ [
860       lua.pkgs.luarocks-build-treesitter-parser-cpp
861     ];
862   });
864   vstruct = prev.vstruct.overrideAttrs (_: {
865     meta.broken = (luaOlder "5.1" || luaAtLeast "5.4");
866   });
868   vusted = prev.vusted.overrideAttrs (_: {
869     postConfigure = ''
870       cat ''${rockspecFilename}
871       substituteInPlace ''${rockspecFilename} \
872         --replace-fail '"luasystem = 0.2.1",' "'luasystem >= 0.2',"
873     '';
875     # make sure vusted_entry.vim doesn't get wrapped
876     postInstall = ''
877       chmod -x $out/bin/vusted_entry.vim
878     '';
879   });
882   # aliases
883   cjson = prev.lua-cjson;