-
-
Notifications
You must be signed in to change notification settings - Fork 14.1k
/
package.nix
286 lines (268 loc) · 8.02 KB
/
package.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
{
lib,
stdenv,
fetchFromGitHub,
removeReferencesTo,
cmake,
gettext,
msgpack-c,
darwin,
libuv,
lua,
pkg-config,
unibilium,
libvterm-neovim,
tree-sitter,
fetchurl,
buildPackages,
treesitter-parsers ? import ./treesitter-parsers.nix { inherit fetchurl; },
fixDarwinDylibNames,
glibcLocales ? null,
procps ? null,
# now defaults to false because some tests can be flaky (clipboard etc), see
# also: https://github.com/neovim/neovim/issues/16233
nodejs ? null,
fish ? null,
python3 ? null,
}:
stdenv.mkDerivation (
finalAttrs:
let
nvim-lpeg-dylib =
luapkgs:
if stdenv.hostPlatform.isDarwin then
let
luaLibDir = "$out/lib/lua/${lib.versions.majorMinor luapkgs.lua.luaversion}";
in
(luapkgs.lpeg.overrideAttrs (oa: {
preConfigure = ''
# neovim wants clang .dylib
substituteInPlace Makefile \
--replace-fail "CC = gcc" "CC = clang" \
--replace-fail "-bundle" "-dynamiclib" \
--replace-fail "lpeg.so" "lpeg.dylib"
'';
preBuild = ''
# there seems to be implicit calls to Makefile from luarocks, we need to
# add a stage to build our dylib
make macosx
mkdir -p ${luaLibDir}
mv lpeg.dylib ${luaLibDir}/lpeg.dylib
'';
postInstall = ''
rm -f ${luaLibDir}/lpeg.so
'';
nativeBuildInputs =
oa.nativeBuildInputs ++ (lib.optional stdenv.hostPlatform.isDarwin fixDarwinDylibNames);
}))
else
luapkgs.lpeg;
requiredLuaPkgs =
ps:
(
with ps;
[
(nvim-lpeg-dylib ps)
luabitop
mpack
]
++ lib.optionals finalAttrs.finalPackage.doCheck [
luv
coxpcall
busted
luafilesystem
penlight
inspect
]
);
neovimLuaEnv = lua.withPackages requiredLuaPkgs;
neovimLuaEnvOnBuild = lua.luaOnBuild.withPackages requiredLuaPkgs;
codegenLua =
if lua.luaOnBuild.pkgs.isLuaJIT then
let
deterministicLuajit = lua.luaOnBuild.override {
deterministicStringIds = true;
self = deterministicLuajit;
};
in
deterministicLuajit.withPackages (ps: [
ps.mpack
(nvim-lpeg-dylib ps)
])
else
lua.luaOnBuild;
in
{
pname = "neovim-unwrapped";
version = "0.10.2";
__structuredAttrs = true;
src = fetchFromGitHub {
owner = "neovim";
repo = "neovim";
rev = "refs/tags/v${finalAttrs.version}";
hash = "sha256-+qjjelYMB3MyjaESfCaGoeBURUzSVh/50uxUqStxIfY=";
};
patches = [
# introduce a system-wide rplugin.vim in addition to the user one
# necessary so that nix can handle `UpdateRemotePlugins` for the plugins
# it installs. See https://github.com/neovim/neovim/issues/9413.
./system_rplugin_manifest.patch
];
dontFixCmake = true;
inherit lua;
treesitter-parsers =
treesitter-parsers
// {
markdown = treesitter-parsers.markdown // {
location = "tree-sitter-markdown";
};
}
// {
markdown_inline = treesitter-parsers.markdown // {
language = "markdown_inline";
location = "tree-sitter-markdown-inline";
};
};
buildInputs =
[
libuv
libvterm-neovim
# This is actually a c library, hence it's not included in neovimLuaEnv,
# see:
# https://github.com/luarocks/luarocks/issues/1402#issuecomment-1080616570
# and it's definition at: pkgs/development/lua-modules/overrides.nix
lua.pkgs.libluv
msgpack-c
neovimLuaEnv
tree-sitter
unibilium
]
++ lib.optionals stdenv.hostPlatform.isDarwin [ darwin.libutil ]
++ lib.optionals finalAttrs.finalPackage.doCheck [
glibcLocales
procps
];
doCheck = false;
# to be exhaustive, one could run
# make oldtests too
checkPhase = ''
runHook preCheck
make functionaltest
runHook postCheck
'';
nativeBuildInputs = [
cmake
gettext
pkg-config
removeReferencesTo
];
# extra programs test via `make functionaltest`
nativeCheckInputs =
let
pyEnv = python3.withPackages (
ps: with ps; [
pynvim
msgpack
]
);
in
[
fish
nodejs
pyEnv # for src/clint.py
];
# nvim --version output retains compilation flags and references to build tools
postPatch =
''
substituteInPlace src/nvim/version.c --replace NVIM_VERSION_CFLAGS "";
''
+ lib.optionalString (!stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
sed -i runtime/CMakeLists.txt \
-e "s|\".*/bin/nvim|\${stdenv.hostPlatform.emulator buildPackages} &|g"
sed -i src/nvim/po/CMakeLists.txt \
-e "s|\$<TARGET_FILE:nvim|\${stdenv.hostPlatform.emulator buildPackages} &|g"
'';
postInstall = ''
find "$out" -type f -exec remove-references-to -t ${stdenv.cc} '{}' +
'';
# check that the above patching actually works
outputChecks =
let
disallowedRequisites = [ stdenv.cc ] ++ lib.optional (lua != codegenLua) codegenLua;
in
{
out = {
inherit disallowedRequisites;
};
debug = {
inherit disallowedRequisites;
};
};
cmakeFlags =
[
# Don't use downloaded dependencies. At the end of the configurePhase one
# can spot that cmake says this option was "not used by the project".
# That's because all dependencies were found and
# third-party/CMakeLists.txt is not read at all.
"-DUSE_BUNDLED=OFF"
]
++ lib.optional (!lua.pkgs.isLuaJIT) "-DPREFER_LUA=ON"
++ lib.optionals lua.pkgs.isLuaJIT [
"-DLUAC_PRG=${codegenLua}/bin/luajit -b -s %s -"
"-DLUA_GEN_PRG=${codegenLua}/bin/luajit"
"-DLUA_PRG=${neovimLuaEnvOnBuild}/bin/luajit"
];
preConfigure =
lib.optionalString stdenv.hostPlatform.isDarwin ''
substituteInPlace src/nvim/CMakeLists.txt --replace " util" ""
''
+ ''
mkdir -p $out/lib/nvim/parser
''
+ lib.concatStrings (
lib.mapAttrsToList (language: grammar: ''
ln -s \
${
tree-sitter.buildGrammar {
inherit (grammar) src;
version = "neovim-${finalAttrs.version}";
language = grammar.language or language;
location = grammar.location or null;
}
}/parser \
$out/lib/nvim/parser/${language}.so
'') finalAttrs.treesitter-parsers
);
shellHook = ''
export VIMRUNTIME=$PWD/runtime
'';
separateDebugInfo = true;
meta = {
description = "Vim text editor fork focused on extensibility and agility";
longDescription = ''
Neovim is a project that seeks to aggressively refactor Vim in order to:
- Simplify maintenance and encourage contributions
- Split the work between multiple developers
- Enable the implementation of new/modern user interfaces without any
modifications to the core source
- Improve extensibility with a new plugin architecture
'';
homepage = "https://www.neovim.io";
mainProgram = "nvim";
# "Contributions committed before b17d96 by authors who did not sign the
# Contributor License Agreement (CLA) remain under the Vim license.
# Contributions committed after b17d96 are licensed under Apache 2.0 unless
# those contributions were copied from Vim (identified in the commit logs
# by the vim-patch token). See LICENSE for details."
license = with lib.licenses; [
asl20
vim
];
maintainers = with lib.maintainers; [
manveru
rvolosatovs
];
platforms = lib.platforms.unix;
};
}
)