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
|
{
lib,
emptyFile,
lua,
makeBinaryWrapper,
neovim-unwrapped,
neovimUtils,
runCommand,
writeText,
}:
{
pname ? lib.removeSuffix "-unwrapped" neovim-unwrapped.pname,
version ? neovim-unwrapped.version,
name ? "${pname}-${version}",
makeWrapperArgs ? [ ],
luaPluginPackages ? _: [ ],
vimPluginPackages ? [ ],
runtimePrograms ? [ ],
luaRc ? emptyFile,
...
}:
let
luaEnv = lua.withPackages luaPluginPackages;
normalizedPlugins = neovimUtils.normalizePlugins vimPluginPackages;
neovimPackage = neovimUtils.normalizedPluginsToVimPackage normalizedPlugins;
packDir = neovimUtils.packDir { inherit neovimPackage; };
vendorRc = writeText "vendor.vim" ''
lua package.path = "${luaEnv.luaPath}"; package.cpath = "${luaEnv.luaCpath}"
set packpath^=${packDir} | set runtimepath^=${packDir}
luafile ${luaRc}
'';
flags = [
"-u"
(toString vendorRc)
];
in
runCommand name
{
__structuredAttrs = true;
nativeBuildInputs = [ makeBinaryWrapper ];
makeWrapperArgs = makeWrapperArgs ++ [
"--add-flags"
(lib.escapeShellArgs flags)
"--suffix"
"PATH"
":"
(lib.makeBinPath runtimePrograms)
];
passthru = {
inherit luaEnv;
};
meta = {
inherit (neovim-unwrapped.meta) description mainProgram;
};
}
''
makeWrapper ${lib.getExe neovim-unwrapped} $out/bin/nvim "''${makeWrapperArgs[@]}"
''
|