biglybt: 3.5.0.0 -> 3.6.0.0
[NixPkgs.git] / pkgs / applications / editors / neovim / default.nix
blobb29e020cbf612863054b12193d57ed36eca31565
1 { lib, stdenv, fetchFromGitHub, removeReferencesTo, cmake, gettext, msgpack-c, libtermkey, libiconv
2 , libuv, lua, ncurses, pkg-config
3 , unibilium, gperf
4 , libvterm-neovim
5 , tree-sitter
6 , fetchurl
7 , buildPackages
8 , treesitter-parsers ? import ./treesitter-parsers.nix { inherit fetchurl; }
9 , CoreServices
10 , fixDarwinDylibNames
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:
18   let
19   nvim-lpeg-dylib = luapkgs: if stdenv.isDarwin
20     then (luapkgs.lpeg.overrideAttrs (oa: {
21       preConfigure = ''
22         # neovim wants clang .dylib
23         sed -i makefile -e "s/CC = gcc/CC = clang/"
24         sed -i makefile -e "s/-bundle/-dynamiclib/"
25       '';
26       preBuild = ''
27         # there seems to be implicit calls to Makefile from luarocks, we need to
28         # add a stage to build our dylib
29         make macosx
30         mkdir -p $out/lib
31         mv lpeg.so $out/lib/lpeg.dylib
32       '';
33       nativeBuildInputs =
34         oa.nativeBuildInputs
35         ++ (
36           lib.optional stdenv.isDarwin fixDarwinDylibNames
37         );
38     }))
39     else luapkgs.lpeg;
40   requiredLuaPkgs = ps: (with ps; [
41     (nvim-lpeg-dylib ps)
42     luabitop
43     mpack
44   ] ++ lib.optionals finalAttrs.doCheck [
45     luv
46     coxpcall
47     busted
48     luafilesystem
49     penlight
50     inspect
51   ]
52   );
53   neovimLuaEnv = lua.withPackages requiredLuaPkgs;
54   neovimLuaEnvOnBuild = lua.luaOnBuild.withPackages requiredLuaPkgs;
55   codegenLua =
56     if lua.luaOnBuild.pkgs.isLuaJIT
57       then
58         let deterministicLuajit =
59           lua.luaOnBuild.override {
60             deterministicStringIds = true;
61             self = deterministicLuajit;
62           };
63         in deterministicLuajit.withPackages(ps: [ ps.mpack (nvim-lpeg-dylib ps) ])
64       else lua.luaOnBuild;
67 in {
68     pname = "neovim-unwrapped";
69     version = "0.9.5";
71     __structuredAttrs = true;
73     src = fetchFromGitHub {
74       owner = "neovim";
75       repo = "neovim";
76       rev = "v${finalAttrs.version}";
77       hash = "sha256-CcaBqA0yFCffNPmXOJTo8c9v1jrEBiqAl8CG5Dj5YxE=";
78     };
80     patches = [
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
85     ];
87     dontFixCmake = true;
89     inherit lua treesitter-parsers;
91     buildInputs = [
92       gperf
93       libtermkey
94       libuv
95       libvterm-neovim
96       # This is actually a c library, hence it's not included in neovimLuaEnv,
97       # see:
98       # https://github.com/luarocks/luarocks/issues/1402#issuecomment-1080616570
99       # and it's definition at: pkgs/development/lua-modules/overrides.nix
100       lua.pkgs.libluv
101       msgpack-c
102       ncurses
103       neovimLuaEnv
104       tree-sitter
105       unibilium
106     ] ++ lib.optionals stdenv.isDarwin [ libiconv CoreServices ]
107       ++ lib.optionals finalAttrs.doCheck [ glibcLocales procps ]
108     ;
110     doCheck = false;
112     # to be exhaustive, one could run
113     # make oldtests too
114     checkPhase = ''
115       runHook preCheck
116       make functionaltest
117       runHook postCheck
118     '';
120     nativeBuildInputs = [
121       cmake
122       gettext
123       pkg-config
124       removeReferencesTo
125     ];
127     # extra programs test via `make functionaltest`
128     nativeCheckInputs = let
129       pyEnv = python3.withPackages(ps: with ps; [ pynvim msgpack ]);
130     in [
131       fish
132       nodejs
133       pyEnv      # for src/clint.py
134     ];
136     # nvim --version output retains compilation flags and references to build tools
137     postPatch = ''
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"
144     '';
145     postInstall = ''
146       find "$out" -type f -exec remove-references-to -t ${stdenv.cc} '{}' +
147     '';
148     # check that the above patching actually works
149     disallowedRequisites = [ stdenv.cc ] ++ lib.optional (lua != codegenLua) codegenLua;
151     cmakeFlags = [
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.
156       "-DUSE_BUNDLED=OFF"
157     ]
158     ++ lib.optional (!lua.pkgs.isLuaJIT) "-DPREFER_LUA=ON"
159     ;
161     preConfigure = lib.optionalString lua.pkgs.isLuaJIT ''
162       cmakeFlagsArray+=(
163         "-DLUAC_PRG=${codegenLua}/bin/luajit -b -s %s -"
164         "-DLUA_GEN_PRG=${codegenLua}/bin/luajit"
165         "-DLUA_PRG=${neovimLuaEnvOnBuild}/bin/luajit"
166       )
167     '' + lib.optionalString stdenv.isDarwin ''
168       substituteInPlace src/nvim/CMakeLists.txt --replace "    util" ""
169     '' + ''
170       mkdir -p $out/lib/nvim/parser
171     '' + lib.concatStrings (lib.mapAttrsToList
172       (language: src: ''
173         ln -s \
174           ${tree-sitter.buildGrammar {
175             inherit language src;
176             version = "neovim-${finalAttrs.version}";
177           }}/parser \
178           $out/lib/nvim/parser/${language}.so
179       '')
180       finalAttrs.treesitter-parsers);
182     shellHook=''
183       export VIMRUNTIME=$PWD/runtime
184     '';
186     separateDebugInfo = true;
188     meta = with lib; {
189       description = "Vim text editor fork focused on extensibility and agility";
190       longDescription = ''
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
197       '';
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;
208     };
209   })