1 { lib, stdenv, fetchFromGitHub, removeReferencesTo, cmake, gettext, msgpack-c, libtermkey, libiconv
2 , libuv, lua, ncurses, pkg-config
8 , treesitter-parsers ? import ./treesitter-parsers.nix { inherit fetchurl; }
11 , glibcLocales ? null, procps ? null
13 # now defaults to false because some tests can be flaky (clipboard etc), see
14 # also: https://github.com/neovim/neovim/issues/16233
15 , nodejs ? null, fish ? null, python3 ? null
17 stdenv.mkDerivation (finalAttrs:
19 nvim-lpeg-dylib = luapkgs: if stdenv.isDarwin
20 then (luapkgs.lpeg.overrideAttrs (oa: {
22 # neovim wants clang .dylib
23 sed -i makefile -e "s/CC = gcc/CC = clang/"
24 sed -i makefile -e "s/-bundle/-dynamiclib/"
27 # there seems to be implicit calls to Makefile from luarocks, we need to
28 # add a stage to build our dylib
31 mv lpeg.so $out/lib/lpeg.dylib
36 lib.optional stdenv.isDarwin fixDarwinDylibNames
40 requiredLuaPkgs = ps: (with ps; [
44 ] ++ lib.optionals finalAttrs.doCheck [
53 neovimLuaEnv = lua.withPackages requiredLuaPkgs;
54 neovimLuaEnvOnBuild = lua.luaOnBuild.withPackages requiredLuaPkgs;
56 if lua.luaOnBuild.pkgs.isLuaJIT
58 let deterministicLuajit =
59 lua.luaOnBuild.override {
60 deterministicStringIds = true;
61 self = deterministicLuajit;
63 in deterministicLuajit.withPackages(ps: [ ps.mpack (nvim-lpeg-dylib ps) ])
68 pname = "neovim-unwrapped";
71 __structuredAttrs = true;
73 src = fetchFromGitHub {
76 rev = "v${finalAttrs.version}";
77 hash = "sha256-CcaBqA0yFCffNPmXOJTo8c9v1jrEBiqAl8CG5Dj5YxE=";
81 # introduce a system-wide rplugin.vim in addition to the user one
82 # necessary so that nix can handle `UpdateRemotePlugins` for the plugins
83 # it installs. See https://github.com/neovim/neovim/issues/9413.
84 ./system_rplugin_manifest.patch
89 inherit lua treesitter-parsers;
96 # This is actually a c library, hence it's not included in neovimLuaEnv,
98 # https://github.com/luarocks/luarocks/issues/1402#issuecomment-1080616570
99 # and it's definition at: pkgs/development/lua-modules/overrides.nix
106 ] ++ lib.optionals stdenv.isDarwin [ libiconv CoreServices ]
107 ++ lib.optionals finalAttrs.doCheck [ glibcLocales procps ]
112 # to be exhaustive, one could run
120 nativeBuildInputs = [
127 # extra programs test via `make functionaltest`
128 nativeCheckInputs = let
129 pyEnv = python3.withPackages(ps: with ps; [ pynvim msgpack ]);
133 pyEnv # for src/clint.py
136 # nvim --version output retains compilation flags and references to build tools
138 substituteInPlace src/nvim/version.c --replace NVIM_VERSION_CFLAGS "";
139 '' + lib.optionalString (!stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
140 sed -i runtime/CMakeLists.txt \
141 -e "s|\".*/bin/nvim|\${stdenv.hostPlatform.emulator buildPackages} &|g"
142 sed -i src/nvim/po/CMakeLists.txt \
143 -e "s|\$<TARGET_FILE:nvim|\${stdenv.hostPlatform.emulator buildPackages} &|g"
146 find "$out" -type f -exec remove-references-to -t ${stdenv.cc} '{}' +
148 # check that the above patching actually works
149 disallowedRequisites = [ stdenv.cc ] ++ lib.optional (lua != codegenLua) codegenLua;
152 # Don't use downloaded dependencies. At the end of the configurePhase one
153 # can spot that cmake says this option was "not used by the project".
154 # That's because all dependencies were found and
155 # third-party/CMakeLists.txt is not read at all.
158 ++ lib.optional (!lua.pkgs.isLuaJIT) "-DPREFER_LUA=ON"
161 preConfigure = lib.optionalString lua.pkgs.isLuaJIT ''
163 "-DLUAC_PRG=${codegenLua}/bin/luajit -b -s %s -"
164 "-DLUA_GEN_PRG=${codegenLua}/bin/luajit"
165 "-DLUA_PRG=${neovimLuaEnvOnBuild}/bin/luajit"
167 '' + lib.optionalString stdenv.isDarwin ''
168 substituteInPlace src/nvim/CMakeLists.txt --replace " util" ""
170 mkdir -p $out/lib/nvim/parser
171 '' + lib.concatStrings (lib.mapAttrsToList
174 ${tree-sitter.buildGrammar {
175 inherit language src;
176 version = "neovim-${finalAttrs.version}";
178 $out/lib/nvim/parser/${language}.so
180 finalAttrs.treesitter-parsers);
183 export VIMRUNTIME=$PWD/runtime
186 separateDebugInfo = true;
189 description = "Vim text editor fork focused on extensibility and agility";
191 Neovim is a project that seeks to aggressively refactor Vim in order to:
192 - Simplify maintenance and encourage contributions
193 - Split the work between multiple developers
194 - Enable the implementation of new/modern user interfaces without any
195 modifications to the core source
196 - Improve extensibility with a new plugin architecture
198 homepage = "https://www.neovim.io";
199 mainProgram = "nvim";
200 # "Contributions committed before b17d96 by authors who did not sign the
201 # Contributor License Agreement (CLA) remain under the Vim license.
202 # Contributions committed after b17d96 are licensed under Apache 2.0 unless
203 # those contributions were copied from Vim (identified in the commit logs
204 # by the vim-patch token). See LICENSE for details."
205 license = with licenses; [ asl20 vim ];
206 maintainers = with maintainers; [ manveru rvolosatovs ];
207 platforms = platforms.unix;