You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

default.nix 4.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. { stdenv, fetchFromGitHub, cmake, gettext, msgpack, libtermkey, libiconv
  2. , libuv, lua, ncurses, pkgconfig
  3. , unibilium, xsel, gperf
  4. , libvterm-neovim
  5. , withJemalloc ? true, jemalloc
  6. , glibcLocales ? null, procps ? null
  7. # now defaults to false because some tests can be flaky (clipboard etc)
  8. , doCheck ? false
  9. }:
  10. with stdenv.lib;
  11. let
  12. neovimLuaEnv = lua.withPackages(ps:
  13. (with ps; [ lpeg luabitop mpack ]
  14. ++ optionals doCheck [
  15. nvim-client luv coxpcall busted luafilesystem penlight inspect
  16. ]
  17. ));
  18. in
  19. stdenv.mkDerivation rec {
  20. pname = "neovim-unwrapped";
  21. version = "0.4.2";
  22. src = fetchFromGitHub {
  23. owner = "neovim";
  24. repo = "neovim";
  25. rev = "v${version}";
  26. sha256 = "13w446plvgl219lhj29jyimhiqvs1y1byrz4qpdmxgyddmx9xqss";
  27. };
  28. patches = [
  29. # introduce a system-wide rplugin.vim in addition to the user one
  30. # necessary so that nix can handle `UpdateRemotePlugins` for the plugins
  31. # it installs. See https://github.com/neovim/neovim/issues/9413.
  32. ./system_rplugin_manifest.patch
  33. ];
  34. dontFixCmake = true;
  35. enableParallelBuilding = true;
  36. buildInputs = [
  37. gperf
  38. libtermkey
  39. libuv
  40. libvterm-neovim
  41. lua.pkgs.luv.libluv
  42. msgpack
  43. ncurses
  44. neovimLuaEnv
  45. unibilium
  46. ] ++ optional withJemalloc jemalloc
  47. ++ optional stdenv.isDarwin libiconv
  48. ++ optionals doCheck [ glibcLocales procps ]
  49. ;
  50. inherit doCheck;
  51. # to be exhaustive, one could run
  52. # make oldtests too
  53. checkPhase = ''
  54. make functionaltest
  55. '';
  56. nativeBuildInputs = [
  57. cmake
  58. gettext
  59. pkgconfig
  60. ];
  61. # nvim --version output retains compilation flags and references to build tools
  62. postPatch = ''
  63. substituteInPlace src/nvim/version.c --replace NVIM_VERSION_CFLAGS "";
  64. '';
  65. # check that the above patching actually works
  66. disallowedReferences = [ stdenv.cc ];
  67. cmakeFlags = [
  68. "-DGPERF_PRG=${gperf}/bin/gperf"
  69. "-DLUA_PRG=${neovimLuaEnv.interpreter}"
  70. ]
  71. # FIXME: this is verry messy and strange.
  72. ++ optional (!stdenv.isDarwin) "-DLIBLUV_LIBRARY=${lua.pkgs.luv}/lib/lua/${lua.luaversion}/luv.so"
  73. ++ optional (stdenv.isDarwin) "-DLIBLUV_LIBRARY=${lua.pkgs.luv.libluv}/lib/lua/${lua.luaversion}/libluv.dylib"
  74. ++ optional doCheck "-DBUSTED_PRG=${neovimLuaEnv}/bin/busted"
  75. ++ optional (!lua.pkgs.isLuaJIT) "-DPREFER_LUA=ON"
  76. ;
  77. # triggers on buffer overflow bug while running tests
  78. hardeningDisable = [ "fortify" ];
  79. preConfigure = stdenv.lib.optionalString stdenv.isDarwin ''
  80. export DYLD_LIBRARY_PATH=${jemalloc}/lib
  81. substituteInPlace src/nvim/CMakeLists.txt --replace " util" ""
  82. '';
  83. postInstall = stdenv.lib.optionalString stdenv.isLinux ''
  84. sed -i -e "s|'xsel|'${xsel}/bin/xsel|g" $out/share/nvim/runtime/autoload/provider/clipboard.vim
  85. '' + stdenv.lib.optionalString (withJemalloc && stdenv.isDarwin) ''
  86. install_name_tool -change libjemalloc.1.dylib \
  87. ${jemalloc}/lib/libjemalloc.1.dylib \
  88. $out/bin/nvim
  89. '';
  90. # export PATH=$PWD/build/bin:${PATH}
  91. shellHook=''
  92. export VIMRUNTIME=$PWD/runtime
  93. '';
  94. meta = {
  95. description = "Vim text editor fork focused on extensibility and agility";
  96. longDescription = ''
  97. Neovim is a project that seeks to aggressively refactor Vim in order to:
  98. - Simplify maintenance and encourage contributions
  99. - Split the work between multiple developers
  100. - Enable the implementation of new/modern user interfaces without any
  101. modifications to the core source
  102. - Improve extensibility with a new plugin architecture
  103. '';
  104. homepage = https://www.neovim.io;
  105. # "Contributions committed before b17d96 by authors who did not sign the
  106. # Contributor License Agreement (CLA) remain under the Vim license.
  107. # Contributions committed after b17d96 are licensed under Apache 2.0 unless
  108. # those contributions were copied from Vim (identified in the commit logs
  109. # by the vim-patch token). See LICENSE for details."
  110. license = with licenses; [ asl20 vim ];
  111. maintainers = with maintainers; [ manveru rvolosatovs ];
  112. platforms = platforms.unix;
  113. };
  114. }