@@ -1,15 +1,25 @@
11{ stdenv, fetchFromGitHub, cmake, gettext, msgpack, libtermkey, libiconv
2−, libuv, luaPackages, ncurses, pkgconfig
2+, libuv, lua, ncurses, pkgconfig
33, unibilium, xsel, gperf
44, libvterm-neovim
55, withJemalloc ? true, jemalloc
6+, glibcLocales ? null, procps ? null
7+
8+# now defaults to false because some tests can be flaky (clipboard etc)
9+, doCheck ? false
610}:
711
812with stdenv.lib;
913
1014let
11−
12− neovim = stdenv.mkDerivation rec {
15+ neovimLuaEnv = lua.withPackages(ps:
16+ (with ps; [ mpack lpeg luabitop ]
17+ ++ optionals doCheck [
18+ nvim-client luv coxpcall busted luafilesystem penlight inspect
19+ ]
20+ ));
21+in
22+ stdenv.mkDerivation rec {
1323 name = "neovim-unwrapped-${version}";
1424 version = "0.3.4";
1525
@@ -36,11 +46,20 @@ let
3646 ncurses
3747 libvterm-neovim
3848 unibilium
39− luaPackages.lua
4049 gperf
50+ neovimLuaEnv
4151 ] ++ optional withJemalloc jemalloc
4252 ++ optional stdenv.isDarwin libiconv
43− ++ lualibs;
53+ ++ optionals doCheck [ glibcLocales procps ]
54+ ;
55+
56+ inherit doCheck;
57+
58+ # to be exhaustive, one could run
59+ # make oldtests too
60+ checkPhase = ''
61+ make functionaltest
62+ '';
4463
4564 nativeBuildInputs = [
4665 cmake
@@ -48,10 +67,6 @@ let
4867 pkgconfig
4968 ];
5069
51− LUA_PATH = stdenv.lib.concatStringsSep ";" (map luaPackages.getLuaPath lualibs);
52− LUA_CPATH = stdenv.lib.concatStringsSep ";" (map luaPackages.getLuaCPath lualibs);
53−
54− lualibs = [ luaPackages.mpack luaPackages.lpeg luaPackages.luabitop ];
5570
5671 # nvim --version output retains compilation flags and references to build tools
5772 postPatch = ''
@@ -61,9 +76,11 @@ let
6176 disallowedReferences = [ stdenv.cc ];
6277
6378 cmakeFlags = [
64− "-DLUA_PRG=${luaPackages.lua}/bin/lua"
79+ "-DLUA_PRG=${neovimLuaEnv}/bin/lua"
6580 "-DGPERF_PRG=${gperf}/bin/gperf"
66− ];
81+ ]
82+ ++ optional doCheck "-DBUSTED_PRG=${neovimLuaEnv}/bin/busted"
83+ ;
6784
6885 # triggers on buffer overflow bug while running tests
6986 hardeningDisable = [ "fortify" ];
@@ -81,6 +98,11 @@ let
8198 $out/bin/nvim
8299 '';
83100
101+ # export PATH=$PWD/build/bin:${PATH}
102+ shellHook=''
103+ export VIMRUNTIME=$PWD/runtime
104+ '';
105+
84106 meta = {
85107 description = "Vim text editor fork focused on extensibility and agility";
86108 longDescription = ''
@@ -104,7 +126,4 @@ let
104126 # https://nix-cache.s3.amazonaws.com/log/9ahcb52905d9d417zsskjpc331iailpq-neovim-unwrapped-0.2.2.drv
105127 broken = stdenv.isAarch64;
106128 };
107− };
108−
109−in
110− neovim
129+ }