-
Notifications
You must be signed in to change notification settings - Fork 1
/
wrapper.nix
97 lines (92 loc) · 2.1 KB
/
wrapper.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
{
lib,
writeText,
neovimUtils,
wrapNeovimUnstable,
neovim-unwrapped,
git,
extraName ? "",
vimAlias ? false,
viAlias ? false,
withPython3 ? false,
extraPython3Packages ? (_: [ ]),
extraLuaPackages ? (_: [ ]),
withNodeJs ? false,
withPerl ? false,
withRuby ? false,
repo ? null,
additionalPreInit ? "",
additionalWrapperArgs ? [ ],
extraBinPath ? [ ],
}:
let
binPath = lib.makeBinPath ([ git ] ++ extraBinPath);
preInit =
# lua
''
-- Globals
vim.g.is_nix_package = 1
''
+
lib.optionalString (repo != null) # lua
''
-- Bootstrap cfg
local repo = '${repo}'
local cfg_path = vim.fn.stdpath 'config'
if vim.loop.fs_stat(cfg_path) then
if
vim.fn
.system({
'env',
'-S',
'-i',
'HOME="$HOME"',
'${git}/bin/git',
'-C',
vim.fn.stdpath 'config',
'remote',
'get-url',
'origin',
})
:find(repo, 1, true)
then
return
end
vim.loop.fs_rename(cfg_path, cfg_path .. '_backup_' .. os.date '%H%M%S_%d-%m-%Y')
end
vim.fn.system({ '${git}/bin/git', 'clone', repo, cfg_path })
''
+ additionalPreInit;
config =
let
cfg = neovimUtils.makeNeovimConfig {
inherit extraName;
inherit vimAlias;
inherit viAlias;
inherit withPython3;
inherit extraPython3Packages;
inherit extraLuaPackages;
inherit withNodeJs;
inherit withPerl;
inherit withRuby;
wrapRc = false;
};
in
cfg
// {
wrapperArgs =
cfg.wrapperArgs
++ [
"--suffix"
"PATH"
":"
binPath
]
++ [
"--add-flags"
''--cmd "luafile ${writeText "pre-init.lua" preInit}"''
]
++ additionalWrapperArgs;
};
in
wrapNeovimUnstable neovim-unwrapped config