1 # do not add pkgs, it messes up splicing
23 , gobject-introspection
60 inherit (prev) luaOlder luaAtLeast lua isLuaJIT;
63 argparse = prev.argparse.overrideAttrs(oa: {
66 checkInputs = [ final.busted ];
70 export LUA_PATH="src/?.lua;$LUA_PATH"
75 ##########################################3
76 #### manual fixes for generated packages
77 ##########################################3
78 bit32 = prev.bit32.overrideAttrs (oa: {
79 # Small patch in order to no longer redefine a Lua 5.2 function that Luajit
80 # 2.1 also provides, see https://github.com/LuaJIT/LuaJIT/issues/325 for
85 meta.broken = luaOlder "5.1" || luaAtLeast "5.4";
88 busted = prev.busted.overrideAttrs (oa: {
89 nativeBuildInputs = oa.nativeBuildInputs ++ [
93 substituteInPlace ''${rockspecFilename} \
94 --replace "'lua_cliargs = 3.0-1'," "'lua_cliargs >= 3.0-1',"
97 installShellCompletion --cmd busted \
98 --zsh completions/zsh/_busted \
99 --bash completions/bash/busted.bash
103 cqueues = prev.cqueues.overrideAttrs (oa: rec {
104 # Parse out a version number without the Lua version inserted
105 version = with lib; let
106 version' = prev.cqueues.version;
107 rel = splitVersion version';
109 rev = last (splitString "-" (last rel));
113 meta.broken = luaOlder "5.1" || luaAtLeast "5.4";
115 nativeBuildInputs = oa.nativeBuildInputs ++ [
120 { name = "CRYPTO"; dep = openssl; }
121 { name = "OPENSSL"; dep = openssl; }
124 # Upstream rockspec is pointlessly broken into separate rockspecs, per Lua
125 # version, which doesn't work well for us, so modify it
126 postConfigure = let inherit (prev.cqueues) pname; in
128 # 'all' target auto-detects correct Lua version, which is fine for us as
129 # we only have the right one available :)
130 sed -Ei ''${rockspecFilename} \
131 -e 's|lua == 5.[[:digit:]]|lua >= 5.1, <= 5.3|' \
132 -e 's|build_target = "[^"]+"|build_target = "all"|' \
133 -e 's|version = "[^"]+"|version = "${version}"|'
134 specDir=$(dirname ''${rockspecFilename})
135 cp ''${rockspecFilename} "$specDir/${pname}-${version}.rockspec"
136 rockspecFilename="$specDir/${pname}-${version}.rockspec"
140 fennel = prev.fennel.overrideAttrs(oa: {
141 nativeBuildInputs = oa.nativeBuildInputs ++ [
145 installManPage fennel.1
149 # Until https://github.com/swarn/fzy-lua/pull/8 is merged,
150 # we have to invoke busted manually
151 fzy = prev.fzy.overrideAttrs(oa: {
153 nativeCheckInputs = [ prev.busted ];
159 http = prev.http.overrideAttrs (oa: {
162 name = "invalid-state-progression.patch";
163 url = "https://github.com/daurnimator/lua-http/commit/cb7b59474a.diff";
164 sha256 = "1vmx039n3nqfx50faqhs3wgiw28ws416rhw6vh6srmh9i826dac7";
167 /* TODO: separate docs derivation? (pandoc is heavy)
168 nativeBuildInputs = [ pandoc ];
169 makeFlags = [ "-C doc" "lua-http.html" "lua-http.3" ];
173 image-nvim = prev.image-nvim.overrideAttrs (oa: {
174 propagatedBuildInputs = [
176 luajitPackages.magick
180 ldbus = prev.ldbus.overrideAttrs (oa: {
181 luarocksConfig = oa.luarocksConfig // {
183 DBUS_DIR = "${dbus.lib}";
184 DBUS_ARCH_INCDIR = "${dbus.lib}/lib/dbus-1.0/include";
185 DBUS_INCDIR = "${dbus.dev}/include/dbus-1.0";
193 ljsyscall = prev.ljsyscall.overrideAttrs (oa: rec {
194 version = "unstable-20180515";
195 # package hasn't seen any release for a long time
196 src = fetchFromGitHub {
197 owner = "justincormack";
199 rev = "e587f8c55aad3955dddab3a4fa6c1968037b5c6e";
200 sha256 = "06v52agqyziwnbp2my3r7liv245ddmb217zmyqakh0ldjdsr8lz4";
202 knownRockspec = "rockspec/ljsyscall-scm-1.rockspec";
203 # actually library works fine with lua 5.2
205 sed -i 's/lua == 5.1/lua >= 5.1, < 5.3/' ${knownRockspec}
207 meta.broken = luaOlder "5.1" || luaAtLeast "5.3";
209 propagatedBuildInputs = with lib; oa.propagatedBuildInputs ++ optional (!isLuaJIT) final.luaffi;
212 lgi = prev.lgi.overrideAttrs (oa: {
213 nativeBuildInputs = oa.nativeBuildInputs ++ [
218 gobject-introspection
222 name = "lgi-find-cairo-through-typelib.patch";
223 url = "https://github.com/psychon/lgi/commit/46a163d9925e7877faf8a4f73996a20d7cf9202a.patch";
224 sha256 = "0gfvvbri9kyzhvq3bvdbj2l6mwvlz040dk4mrd5m9gz79f7w109c";
228 # https://github.com/lgi-devs/lgi/pull/300
230 substituteInPlace lgi/Makefile tests/Makefile \
231 --replace 'PKG_CONFIG =' 'PKG_CONFIG ?='
234 # there is only a rockspec.in in the repo, the actual rockspec must be generated
240 lmathx = prev.luaLib.overrideLuarocks prev.lmathx (drv:
241 if luaAtLeast "5.1" && luaOlder "5.2" then {
242 version = "20120430.51-1";
243 knownRockspec = (fetchurl {
244 url = "https://luarocks.org/lmathx-20120430.51-1.rockspec";
245 sha256 = "148vbv2g3z5si2db7rqg5bdily7m4sjyh9w6r3jnx3csvfaxyhp0";
248 url = "https://web.tecgraf.puc-rio.br/~lhf/ftp/lua/5.1/lmathx.tar.gz";
249 sha256 = "0sa553d0zlxhvpsmr4r7d841f16yq4wr3fg7i07ibxkz6yzxax51";
252 if luaAtLeast "5.2" && luaOlder "5.3" then {
253 version = "20120430.52-1";
254 knownRockspec = (fetchurl {
255 url = "https://luarocks.org/lmathx-20120430.52-1.rockspec";
256 sha256 = "14rd625sipakm72wg6xqsbbglaxyjba9nsajsfyvhg0sz8qjgdya";
259 url = "http://www.tecgraf.puc-rio.br/~lhf/ftp/lua/5.2/lmathx.tar.gz";
260 sha256 = "19dwa4z266l2njgi6fbq9rak4rmx2fsx1s0p9sl166ar3mnrdwz5";
264 disabled = luaOlder "5.1" || luaAtLeast "5.5";
265 # works fine with 5.4 as well
267 substituteInPlace ''${rockspecFilename} \
268 --replace 'lua ~> 5.3' 'lua >= 5.3, < 5.5'
272 lmpfrlib = prev.lmpfrlib.overrideAttrs (oa: {
274 { name = "GMP"; dep = gmp; }
275 { name = "MPFR"; dep = mpfr; }
278 cp $src $(stripHash $src)
282 lrexlib-gnu = prev.lrexlib-gnu.overrideAttrs (oa: {
283 buildInputs = oa.buildInputs ++ [
288 lrexlib-pcre = prev.lrexlib-pcre.overrideAttrs (oa: {
290 { name = "PCRE"; dep = pcre; }
294 lrexlib-posix = prev.lrexlib-posix.overrideAttrs (oa: {
295 buildInputs = oa.buildInputs ++ [
300 lua-curl = prev.lua-curl.overrideAttrs (oa: {
301 buildInputs = oa.buildInputs ++ [
306 lua-iconv = prev.lua-iconv.overrideAttrs (oa: {
307 buildInputs = oa.buildInputs ++ [
312 lua-lsp = prev.lua-lsp.overrideAttrs (oa: {
313 # until Alloyed/lua-lsp#28
315 substituteInPlace ''${rockspecFilename} \
316 --replace '"dkjson ~> 2.5",' '"dkjson >= 2.5",'
320 lua-zlib = prev.lua-zlib.overrideAttrs (oa: {
321 buildInputs = oa.buildInputs ++ [
324 meta.broken = luaOlder "5.1" || luaAtLeast "5.4";
327 luadbi-mysql = prev.luadbi-mysql.overrideAttrs (oa: {
329 luarocksConfig = lib.recursiveUpdate oa.luarocksConfig {
331 # Can't just be /include and /lib, unfortunately needs the trailing 'mysql'
332 MYSQL_INCDIR = "${libmysqlclient.dev}/include/mysql";
333 MYSQL_LIBDIR = "${libmysqlclient}/lib/mysql";
336 buildInputs = oa.buildInputs ++ [
342 luadbi-postgresql = prev.luadbi-postgresql.overrideAttrs (oa: {
343 buildInputs = oa.buildInputs ++ [
348 luadbi-sqlite3 = prev.luadbi-sqlite3.overrideAttrs (oa: {
350 { name = "SQLITE"; dep = sqlite; }
354 luaevent = prev.luaevent.overrideAttrs (oa: {
355 propagatedBuildInputs = oa.propagatedBuildInputs ++ [
359 { name = "EVENT"; dep = libevent; }
361 meta.broken = luaOlder "5.1" || luaAtLeast "5.4";
364 luaexpat = prev.luaexpat.overrideAttrs (_: {
366 { name = "EXPAT"; dep = expat; }
370 # TODO Somehow automatically amend buildInputs for things that need luaffi
371 # but are in luajitPackages?
372 luaffi = prev.luaffi.overrideAttrs (oa: {
373 # The packaged .src.rock version is pretty old, and doesn't work with Lua 5.3
374 src = fetchFromGitHub {
377 rev = "532c757e51c86f546a85730b71c9fef15ffa633d";
378 sha256 = "1nwx6sh56zfq99rcs7sph0296jf6a9z72mxknn0ysw9fd7m1r8ig";
380 knownRockspec = with prev.luaffi; "${pname}-${version}.rockspec";
381 meta.broken = luaOlder "5.1" || luaAtLeast "5.4" || isLuaJIT;
384 lualdap = prev.lualdap.overrideAttrs (_: {
386 { name = "LDAP"; dep = openldap; }
390 luaossl = prev.luaossl.overrideAttrs (_: {
392 { name = "CRYPTO"; dep = openssl; }
393 { name = "OPENSSL"; dep = openssl; }
397 luaposix = prev.luaposix.overrideAttrs (_: {
399 { name = "CRYPT"; dep = libxcrypt; }
403 luasec = prev.luasec.overrideAttrs (oa: {
405 { name = "OPENSSL"; dep = openssl; }
409 luasql-sqlite3 = prev.luasql-sqlite3.overrideAttrs (oa: {
411 { name = "SQLITE"; dep = sqlite; }
415 luasystem = prev.luasystem.overrideAttrs (oa: lib.optionalAttrs stdenv.isLinux {
416 buildInputs = [ glibc.out ];
419 luazip = prev.luazip.overrideAttrs (oa: {
420 buildInputs = oa.buildInputs ++ [
425 # lua-resty-session = prev.lua-resty-session.overrideAttrs (oa: {
426 # # lua_pack and lua-ffi-zlib are unpackaged, causing this package to not evaluate
427 # meta.broken = true;
430 lua-yajl = prev.lua-yajl.overrideAttrs (oa: {
431 buildInputs = oa.buildInputs ++ [
436 luaunbound = prev.luaunbound.overrideAttrs (oa: {
438 { name = "libunbound"; dep = unbound; }
442 lua-subprocess = prev.lua-subprocess.overrideAttrs (oa: {
443 meta.broken = luaOlder "5.1" || luaAtLeast "5.4";
446 lua-rtoml = prev.lua-rtoml.overrideAttrs (oa: {
448 cargoDeps = rustPlatform.fetchCargoTarball {
450 hash = "sha256-EcP4eYsuOVeEol+kMqzsVHd8F2KoBdLzf6K0KsYToUY=";
453 propagatedBuildInputs = oa.propagatedBuildInputs ++ [ cargo rustPlatform.cargoSetupHook ];
457 lush-nvim = prev.lush-nvim.overrideAttrs (drv: {
461 luuid = prev.luuid.overrideAttrs (oa: {
463 { name = "LIBUUID"; dep = libuuid; }
465 # Trivial patch to make it work in both 5.1 and 5.2. Basically just the
466 # tiny diff between the two upstream versions placed behind an #if.
468 # 5.1: http://webserver2.tecgraf.puc-rio.br/~lhf/ftp/lua/5.1/luuid.tar.gz
469 # 5.2: http://webserver2.tecgraf.puc-rio.br/~lhf/ftp/lua/5.2/luuid.tar.gz
470 patchFlags = [ "-p2" ];
475 sed -Ei ''${rockspecFilename} -e 's|lua >= 5.2|lua >= 5.1,|'
478 broken = luaOlder "5.1" || (luaAtLeast "5.4");
479 platforms = lib.platforms.linux;
483 haskell-tools-nvim = prev.haskell-tools-nvim.overrideAttrs(oa: {
484 doCheck = lua.luaversion == "5.1";
485 nativeCheckInputs = [ final.nlua final.busted ];
488 export HOME=$(mktemp -d)
494 plenary-nvim = prev.plenary-nvim.overrideAttrs (oa: {
496 sed -Ei lua/plenary/curl.lua \
497 -e 's@(command\s*=\s*")curl(")@\1${curl}/bin/curl\2@'
500 # disabled for now because too flaky
512 # remove failing tests, need internet access for instance
513 rm tests/plenary/job_spec.lua tests/plenary/scandir_spec.lua tests/plenary/curl_spec.lua
514 export HOME="$TMPDIR"
520 # as advised in https://github.com/luarocks/luarocks/issues/1402#issuecomment-1080616570
521 # we shouldn't use luarocks machinery to build complex cmake components
522 libluv = stdenv.mkDerivation {
525 inherit (prev.luv) version meta src;
528 "-DBUILD_SHARED_LIBS=ON"
530 "-DWITH_SHARED_LIBUV=ON"
531 "-DLUA_BUILD_TYPE=System"
532 "-DWITH_LUA_ENGINE=${if isLuaJIT then "LuaJit" else "Lua"}"
535 # to make sure we dont use bundled deps
537 rm -rf deps/lua deps/libuv
540 buildInputs = [ libuv final.lua ];
542 nativeBuildInputs = [ pkg-config cmake ]
543 ++ lib.optionals stdenv.isDarwin [ fixDarwinDylibNames ];
546 luv = prev.luv.overrideAttrs (oa: {
548 nativeBuildInputs = oa.nativeBuildInputs ++ [ pkg-config ];
549 buildInputs = [ libuv ];
551 # Use system libuv instead of building local and statically linking
552 luarocksConfig = lib.recursiveUpdate oa.luarocksConfig {
553 variables = { WITH_SHARED_LIBUV = "ON"; };
556 # we unset the LUA_PATH since the hook erases the interpreter defaults (To fix)
557 # tests is not run since they are not part of the tarball anymore
560 rm tests/test-{dns,thread}.lua
564 lyaml = prev.lyaml.overrideAttrs (oa: {
570 magick = prev.magick.overrideAttrs (oa: {
571 buildInputs = oa.buildInputs ++ [
575 # Fix MagickWand not being found in the pkg-config search path
581 substituteInPlace magick/wand/lib.lua \
582 --replace @nix_wand@ ${imagemagick}/lib/libMagickWand-7.Q16HDRI${stdenv.hostPlatform.extensions.sharedLibrary}
586 meta.broken = !isLuaJIT;
589 mpack = prev.mpack.overrideAttrs (drv: {
590 buildInputs = (drv.buildInputs or []) ++ [ libmpack ];
592 # the rockspec doesn't use the makefile so you may need to export more flags
593 USE_SYSTEM_LUA = "yes";
594 USE_SYSTEM_MPACK = "yes";
598 nlua = prev.nlua.overrideAttrs(oa: {
600 # patchShebang removes the nvim in nlua's shebang so we hardcode one
602 sed -i -e "1 s|.*|#\!${coreutils}/bin/env -S ${neovim-unwrapped}/bin/nvim -l|" "$out/bin/nlua"
604 dontPatchShebangs = true;
607 rapidjson = prev.rapidjson.overrideAttrs (oa: {
609 sed -i '/set(CMAKE_CXX_FLAGS/d' CMakeLists.txt
610 sed -i '/set(CMAKE_C_FLAGS/d' CMakeLists.txt
614 # upstream broken, can't be generated, so moved out from the generated set
615 readline = final.callPackage({ buildLuarocksPackage, fetchurl, luaAtLeast, luaOlder, lua, luaposix }:
616 buildLuarocksPackage ({
619 knownRockspec = (fetchurl {
620 url = "mirror://luarocks/readline-3.2-0.rockspec";
621 sha256 = "1r0sgisxm4xd1r6i053iibxh30j7j3rcj4wwkd8rzkj8nln20z24";
624 # the rockspec url doesn't work because 'www.' is not covered by the certificate so
625 # I manually removed the 'www' prefix here
626 url = "http://pjb.com.au/comp/lua/readline-3.2.tar.gz";
627 sha256 = "1mk9algpsvyqwhnq7jlw4cgmfzj30l7n2r6ak4qxgdxgc39f48k4";
630 luarocksConfig.variables = rec {
631 READLINE_INCDIR = "${readline.dev}/include";
632 HISTORY_INCDIR = READLINE_INCDIR;
639 propagatedBuildInputs = [ lua luaposix
644 homepage = "http://pjb.com.au/comp/lua/readline.html";
645 description = "Interface to the readline library";
646 license.fullName = "MIT/X11";
647 broken = (luaOlder "5.1") || (luaAtLeast "5.5");
652 sqlite = prev.sqlite.overrideAttrs (drv: {
655 nativeCheckInputs = [ final.plenary-nvim neovim-unwrapped ];
657 # we override 'luarocks test' because otherwise neovim doesn't find/load the plenary plugin
659 export LIBSQLITE="${sqlite.out}/lib/libsqlite3${stdenv.hostPlatform.extensions.sharedLibrary}"
660 export HOME="$TMPDIR";
662 nvim --headless -i NONE \
663 -u test/minimal_init.vim --cmd "set rtp+=${vimPlugins.plenary-nvim}" \
664 -c "PlenaryBustedDirectory test/auto/ { minimal_init = './test/minimal_init.vim' }"
669 std-_debug = prev.std-_debug.overrideAttrs (oa: {
670 # run make to generate lib/std/_debug/version.lua
676 std-normalize = prev.std-normalize.overrideAttrs (oa: {
677 # run make to generate lib/std/_debug/version.lua
683 tiktoken_core = prev.tiktoken_core.overrideAttrs (oa: {
684 cargoDeps = rustPlatform.fetchCargoTarball {
686 hash = "sha256-YApsOGfAw34zp069lyGR6FGjxty1bE23+Tic07f8zI4=";
688 nativeBuildInputs = oa.nativeBuildInputs ++ [ cargo rustPlatform.cargoSetupHook ];
691 toml = prev.toml.overrideAttrs (oa: {
692 patches = [ ./toml.patch ];
694 propagatedBuildInputs = oa.propagatedBuildInputs ++ [ magic-enum sol2 ];
697 substituteInPlace CMakeLists.txt --replace \
698 "TOML_PLUS_PLUS_SRC" \
699 "${tomlplusplus.src}"
703 toml-edit = prev.toml-edit.overrideAttrs (oa: {
705 cargoDeps = rustPlatform.fetchCargoTarball {
707 hash = "sha256-2P+mokkjdj2PccQG/kAGnIoUPVnK2FqNfYpHPhsp8kw=";
710 nativeBuildInputs = let
711 # HACK: luarocks-nix doesn't pick up rockspec build dependencies,
712 # so we have to pass the correct package in here.
713 lua = lib.head oa.propagatedBuildInputs;
714 in oa.nativeBuildInputs ++ [
716 rustPlatform.cargoSetupHook
717 lua.pkgs.luarocks-build-rust-mlua
722 vstruct = prev.vstruct.overrideAttrs (_: {
723 meta.broken = (luaOlder "5.1" || luaAtLeast "5.4");
726 vusted = prev.vusted.overrideAttrs (_: {
727 # make sure vusted_entry.vim doesn't get wrapped
729 chmod -x $out/bin/vusted_entry.vim
735 cjson = prev.lua-cjson;