···1-{ lib
2-, stdenv
3-, lua
4-, toVimPlugin
5}:
6let
7 # sanitizeDerivationName
8 normalizeName = lib.replaceStrings [ "." ] [ "-" ];
9in
1011- # function to create vim plugin from lua packages that are already packaged in
12- # luaPackages
13- {
14- # the lua derivation to convert into a neovim plugin
15- luaAttr ? (lua.pkgs.${normalizeName attrs.pname})
16- , ...
17- }@attrs:
18- let
19- originalLuaDrv = if (lib.typeOf luaAttr == "string") then
20- lib.warn "luaAttr as string is deprecated since September 2024. Pass a lua derivation directly ( e.g., `buildNeovimPlugin { luaAttr = lua.pkgs.plenary-nvim; }`)" lua.pkgs.${normalizeName luaAttr}
21- else luaAttr;
0000220002324- luaDrv = originalLuaDrv.overrideAttrs (oa: {
25- version = attrs.version or oa.version;
26- rockspecVersion = oa.rockspecVersion;
27-28- extraConfig = ''
29- -- to create a flat hierarchy
30- lua_modules_path = "lua"
31- '';
32- });
3334- finalDrv = toVimPlugin (luaDrv.overrideAttrs(oa: attrs // {
35- nativeBuildInputs = oa.nativeBuildInputs or [] ++ [
36- lua.pkgs.luarocksMoveDataFolder
37- ];
38- version = "${originalLuaDrv.version}-unstable-${oa.version}";
39- }));
40- in
41- finalDrv
000000
···1+{
2+ lib,
3+ lua,
4+ toVimPlugin,
5}:
6let
7 # sanitizeDerivationName
8 normalizeName = lib.replaceStrings [ "." ] [ "-" ];
9in
1011+# function to create vim plugin from lua packages that are already packaged in
12+# luaPackages
13+{
14+ # the lua derivation to convert into a neovim plugin
15+ luaAttr ? (lua.pkgs.${normalizeName attrs.pname}),
16+ ...
17+}@attrs:
18+let
19+ originalLuaDrv =
20+ if (lib.typeOf luaAttr == "string") then
21+ lib.warn
22+ "luaAttr as string is deprecated since September 2024. Pass a lua derivation directly ( e.g., `buildNeovimPlugin { luaAttr = lua.pkgs.plenary-nvim; }`)"
23+ lua.pkgs.${normalizeName luaAttr}
24+ else
25+ luaAttr;
2627+ luaDrv = originalLuaDrv.overrideAttrs (oa: {
28+ version = attrs.version or oa.version;
29+ rockspecVersion = oa.rockspecVersion;
3031+ extraConfig = ''
32+ -- to create a flat hierarchy
33+ lua_modules_path = "lua"
34+ '';
35+ });
00003637+ finalDrv = toVimPlugin (
38+ luaDrv.overrideAttrs (
39+ oa:
40+ attrs
41+ // {
42+ nativeBuildInputs = oa.nativeBuildInputs or [ ] ++ [
43+ lua.pkgs.luarocksMoveDataFolder
44+ ];
45+ version = "${originalLuaDrv.version}-unstable-${oa.version}";
46+ }
47+ )
48+ );
49+in
50+finalDrv
+4-4
pkgs/applications/editors/neovim/utils.nix
···171 withPython3 ? true,
172 withNodeJs ? false,
173 withRuby ? true,
174- # perl is problematic https://github.com/NixOS/nixpkgs/issues/132368
175 withPerl ? false,
176177 # so that we can pass the full neovim config while ignoring it
···272 ));
273274 /*
275- Fork of vimUtils.packDir that additionnally generates a propagated-build-inputs-file that
276 can be used by the lua hooks to generate a proper LUA_PATH
277278 Generates a packpath folder as expected by vim
···286 rawPackDir = vimUtils.packDir packages;
287288 in
289- rawPackDir.override ({
290 postBuild = ''
291 mkdir $out/nix-support
292 for i in $(find -L $out -name propagated-build-inputs ); do
293 cat "$i" >> $out/nix-support/propagated-build-inputs
294 done
295 '';
296- });
297298in
299{
···171 withPython3 ? true,
172 withNodeJs ? false,
173 withRuby ? true,
174+ # Perl is problematic https://github.com/NixOS/nixpkgs/issues/132368
175 withPerl ? false,
176177 # so that we can pass the full neovim config while ignoring it
···272 ));
273274 /*
275+ Fork of vimUtils.packDir that additionally generates a propagated-build-inputs-file that
276 can be used by the lua hooks to generate a proper LUA_PATH
277278 Generates a packpath folder as expected by vim
···286 rawPackDir = vimUtils.packDir packages;
287288 in
289+ rawPackDir.override {
290 postBuild = ''
291 mkdir $out/nix-support
292 for i in $(find -L $out -name propagated-build-inputs ); do
293 cat "$i" >> $out/nix-support/propagated-build-inputs
294 done
295 '';
296+ };
297298in
299{
+326-254
pkgs/applications/editors/neovim/wrapper.nix
···1-{ stdenv, symlinkJoin, lib, makeWrapper
2-, bundlerEnv
3-, ruby
4-, nodejs
5-, writeText
6-, neovim-node-client
7-, python3
8-, callPackage
9-, neovimUtils
10-, perl
11-, lndir
12-, vimUtils
00013}:
1415neovim-unwrapped:
···18 # inherit interpreter from neovim
19 lua = neovim-unwrapped.lua;
2021- wrapper = {
22- extraName ? ""
23- # certain plugins need a custom configuration (available in passthru.initLua)
24- # to work with nix.
25- # if true, the wrapper automatically appends those snippets when necessary
26- , autoconfigure ? true
02728- # append to PATH runtime deps of plugins
29- , autowrapRuntimeDeps ? true
3031- # should contain all args but the binary. Can be either a string or list
32- , wrapperArgs ? []
33- , withPython2 ? false
34- , withPython3 ? true
35- /* the function you would have passed to python3.withPackages */
36- , extraPython3Packages ? (_: [ ])
3738- , withNodeJs ? false
39- , withPerl ? false
40- , withRuby ? true
4142- # wether to create symlinks in $out/bin/vi(m) -> $out/bin/nvim
43- , vimAlias ? false
44- , viAlias ? false
4546- # additional argument not generated by makeNeovimConfig
47- # it will append "-u <customRc>" to the wrapped arguments
48- # set to false if you want to control where to save the generated config
49- # (e.g., in ~/.config/init.vim or project/.nvimrc)
50- , wrapRc ? true
51- # vimL code that should be sourced as part of the generated init.lua file
52- , neovimRcContent ? null
53- # lua code to put into the generated init.lua file
54- , luaRcContent ? ""
55- # DEPRECATED: entry to load in packpath
56- # use 'plugins' instead
57- , packpathDirs ? null # not used anymore
5859- # a list of neovim plugin derivations, for instance
60- # plugins = [
61- # { plugin=far-vim; config = "let g:far#source='rg'"; optional = false; }
62- # ]
63- , plugins ? []
64- , ...
65- }@attrs:
66- assert withPython2 -> throw "Python2 support has been removed from the neovim wrapper, please remove withPython2 and python2Env.";
006768- assert packpathDirs != null -> throw "packpathdirs is not used anymore: pass a list of neovim plugin derivations in 'plugins' instead.";
006970- stdenv.mkDerivation (finalAttrs:
71- let
72- pluginsNormalized = neovimUtils.normalizePlugins finalAttrs.plugins;
07374- myVimPackage = neovimUtils.normalizedPluginsToVimPackage pluginsNormalized;
7576- rubyEnv = bundlerEnv {
77- name = "neovim-ruby-env";
78- gemdir = ./ruby_provider;
79- postBuild = ''
80- ln -sf ${ruby}/bin/* $out/bin
81- '';
82- };
8384- pluginRC = lib.foldl (acc: p: if p.config != null then acc ++ [p.config] else acc) [] pluginsNormalized;
008586- # a limited RC script used only to generate the manifest for remote plugins
87- manifestRc = "";
88- # we call vimrcContent without 'packages' to avoid the init.vim generation
89- neovimRcContent' = lib.concatStringsSep "\n" (pluginRC ++ lib.optional (neovimRcContent != null) neovimRcContent);
009091- packpathDirs.myNeovimPackages = myVimPackage;
92- finalPackdir = neovimUtils.packDir packpathDirs;
9394- luaPluginRC = let
95- op = acc: normalizedPlugin:
96- acc ++ lib.optional (finalAttrs.autoconfigure && normalizedPlugin.plugin.passthru ? initLua) normalizedPlugin.plugin.passthru.initLua;
97- in
98- lib.foldl' op [] pluginsNormalized;
0000099100- rcContent = ''
101- ${luaRcContent}
102- '' + lib.optionalString (neovimRcContent' != null) ''
103- vim.cmd.source "${writeText "init.vim" neovimRcContent'}"
104- '' +
105- lib.concatStringsSep "\n" luaPluginRC
106- ;
0107108- getDeps = attrname: map (plugin: plugin.${attrname} or (_: [ ]));
109110- requiredPlugins = vimUtils.requiredPluginsForPackage myVimPackage;
111- pluginPython3Packages = getDeps "python3Dependencies" requiredPlugins;
112113- python3Env = lib.warnIf (attrs ? python3Env) "Pass your python packages via the `extraPython3Packages`, e.g., `extraPython3Packages = ps: [ ps.pandas ]`"
114- python3.pkgs.python.withPackages (ps:
115- [ ps.pynvim ]
116- ++ (extraPython3Packages ps)
117- ++ (lib.concatMap (f: f ps) pluginPython3Packages));
1180119120- wrapperArgsStr = if lib.isString wrapperArgs then wrapperArgs else lib.escapeShellArgs wrapperArgs;
0000000000000000000000000000121122- generatedWrapperArgs =
123- [
124- # vim accepts a limited number of commands so we join all the provider ones
125- "--add-flags" ''--cmd "lua ${providerLuaRc}"''
126- ]
127- ++ lib.optionals (finalAttrs.packpathDirs.myNeovimPackages.start != [] || finalAttrs.packpathDirs.myNeovimPackages.opt != []) [
128- "--add-flags" ''--cmd "set packpath^=${finalPackdir}"''
129- "--add-flags" ''--cmd "set rtp^=${finalPackdir}"''
130- ]
131- ++ lib.optionals finalAttrs.withRuby [
132- "--set" "GEM_HOME" "${rubyEnv}/${rubyEnv.ruby.gemPath}"
133- ] ++ lib.optionals (finalAttrs.runtimeDeps != []) [
134- "--suffix" "PATH" ":" (lib.makeBinPath finalAttrs.runtimeDeps)
135- ]
136 ;
137-138- providerLuaRc = neovimUtils.generateProviderRc {
139- inherit (finalAttrs) withPython3 withNodeJs withPerl withRuby;
140- };
141-142- # If configure != {}, we can't generate the rplugin.vim file with e.g
143- # NVIM_SYSTEM_RPLUGIN_MANIFEST *and* NVIM_RPLUGIN_MANIFEST env vars set in
144- # the wrapper. That's why only when configure != {} (tested both here and
145- # when postBuild is evaluated), we call makeWrapper once to generate a
146- # wrapper with most arguments we need, excluding those that cause problems to
147- # generate rplugin.vim, but still required for the final wrapper.
148- finalMakeWrapperArgs =
149- [ "${neovim-unwrapped}/bin/nvim" "${placeholder "out"}/bin/nvim" ]
150- ++ [ "--set" "NVIM_SYSTEM_RPLUGIN_MANIFEST" "${placeholder "out"}/rplugin.vim" ]
151- ++ lib.optionals finalAttrs.wrapRc [ "--add-flags" "-u ${writeText "init.lua" rcContent}" ]
152- ++ finalAttrs.generatedWrapperArgs
153- ;
154-155- perlEnv = perl.withPackages (p: [ p.NeovimExt p.Appcpanminus ]);
156-157- pname = "neovim";
158- version = lib.getVersion neovim-unwrapped;
159- in {
160- name = "${pname}-${version}${extraName}";
161- inherit pname version;
162- inherit plugins;
163164- __structuredAttrs = true;
165- dontUnpack = true;
166- inherit viAlias vimAlias withNodeJs withPython3 withPerl withRuby;
167- inherit autoconfigure autowrapRuntimeDeps wrapRc providerLuaRc packpathDirs;
168- inherit python3Env rubyEnv;
169- inherit wrapperArgs generatedWrapperArgs;
0000000000000001700000171172- runtimeDeps = let
173- op = acc: normalizedPlugin: acc ++ normalizedPlugin.plugin.runtimeDeps or [];
174- runtimeDeps = lib.foldl' op [] pluginsNormalized;
175 in
176- lib.optional finalAttrs.withRuby rubyEnv
177- ++ lib.optional finalAttrs.withNodeJs nodejs
178- ++ lib.optionals finalAttrs.autowrapRuntimeDeps runtimeDeps
00000000000179 ;
00000000018000000000181182- luaRcContent = rcContent;
183- # Remove the symlinks created by symlinkJoin which we need to perform
184- # extra actions upon
185- postBuild = lib.optionalString stdenv.hostPlatform.isLinux ''
186- rm $out/share/applications/nvim.desktop
187- substitute ${neovim-unwrapped}/share/applications/nvim.desktop $out/share/applications/nvim.desktop \
188- --replace-warn 'Name=Neovim' 'Name=Neovim wrapper'
189- ''
190- + lib.optionalString finalAttrs.withPython3 ''
191- makeWrapper ${python3Env.interpreter} $out/bin/nvim-python3 --unset PYTHONPATH --unset PYTHONSAFEPATH
192- ''
193- + lib.optionalString (finalAttrs.withRuby) ''
194- ln -s ${finalAttrs.rubyEnv}/bin/neovim-ruby-host $out/bin/nvim-ruby
195- ''
196- + lib.optionalString finalAttrs.withNodeJs ''
197- ln -s ${neovim-node-client}/bin/neovim-node-host $out/bin/nvim-node
198- ''
199- + lib.optionalString finalAttrs.withPerl ''
200- ln -s ${perlEnv}/bin/perl $out/bin/nvim-perl
201- ''
202- + lib.optionalString finalAttrs.vimAlias ''
203- ln -s $out/bin/nvim $out/bin/vim
204- ''
205- + lib.optionalString finalAttrs.viAlias ''
206- ln -s $out/bin/nvim $out/bin/vi
207- ''
208- + lib.optionalString (manifestRc != null) (let
209- manifestWrapperArgs =
210- [ "${neovim-unwrapped}/bin/nvim" "${placeholder "out"}/bin/nvim-wrapper" ] ++ finalAttrs.generatedWrapperArgs;
211- in ''
212- echo "Generating remote plugin manifest"
213- export NVIM_RPLUGIN_MANIFEST=$out/rplugin.vim
214- makeWrapper ${lib.escapeShellArgs manifestWrapperArgs} ${wrapperArgsStr}
00000215216- # Some plugins assume that the home directory is accessible for
217- # initializing caches, temporary files, etc. Even if the plugin isn't
218- # actively used, it may throw an error as soon as Neovim is launched
219- # (e.g., inside an autoload script), causing manifest generation to
220- # fail. Therefore, let's create a fake home directory before generating
221- # the manifest, just to satisfy the needs of these plugins.
222- #
223- # See https://github.com/Yggdroot/LeaderF/blob/v1.21/autoload/lfMru.vim#L10
224- # for an example of this behavior.
225- export HOME="$(mktemp -d)"
226- # Launch neovim with a vimrc file containing only the generated plugin
227- # code. Pass various flags to disable temp file generation
228- # (swap/viminfo) and redirect errors to stderr.
229- # Only display the log on error since it will contain a few normally
230- # irrelevant messages.
231- if ! $out/bin/nvim-wrapper \
232- -u ${writeText "manifest.vim" manifestRc} \
233- -i NONE -n \
234- -V1rplugins.log \
235- +UpdateRemotePlugins +quit! > outfile 2>&1; then
236- cat outfile
237- echo -e "\nGenerating rplugin.vim failed!"
238- exit 1
239- fi
240- rm "${placeholder "out"}/bin/nvim-wrapper"
241- '')
242- + ''
243- rm $out/bin/nvim
244- touch $out/rplugin.vim
0245246- echo "Looking for lua dependencies..."
247- source ${lua}/nix-support/utils.sh
248249- _addToLuaPath "${finalPackdir}"
250251- echo "LUA_PATH towards the end of packdir: $LUA_PATH"
252253- makeWrapper ${lib.escapeShellArgs finalMakeWrapperArgs} ${wrapperArgsStr} \
254- --prefix LUA_PATH ';' "$LUA_PATH" \
255- --prefix LUA_CPATH ';' "$LUA_CPATH"
256- '';
257258- buildPhase = ''
259- runHook preBuild
260- mkdir -p $out
261- for i in ${neovim-unwrapped}; do
262- lndir -silent $i $out
263- done
264- runHook postBuild
265- '';
266267- preferLocalBuild = true;
268269- nativeBuildInputs = [ makeWrapper lndir ];
000270271- # A Vim "package", see ':h packages'
272- vimPackage = myVimPackage;
273274- checkPhase = ''
275- runHook preCheck
276277- $out/bin/nvim -i NONE -e +quitall!
278- runHook postCheck
279- '';
280281- passthru = {
282- inherit providerLuaRc packpathDirs;
283- unwrapped = neovim-unwrapped;
284- initRc = neovimRcContent';
285286- tests = callPackage ./tests {
287- };
288- };
289290- meta = {
291- inherit (neovim-unwrapped.meta)
292- description
293- longDescription
294- homepage
295- mainProgram
296- license
297- maintainers
298- platforms;
0299300- # To prevent builds on hydra
301- hydraPlatforms = [];
302- # prefer wrapper over the package
303- priority = (neovim-unwrapped.meta.priority or lib.meta.defaultPriority) - 1;
304- };
305- });
0306in
307- lib.makeOverridable wrapper
···1+{
2+ stdenv,
3+ lib,
4+ makeWrapper,
5+ bundlerEnv,
6+ ruby,
7+ nodejs,
8+ writeText,
9+ neovim-node-client,
10+ python3,
11+ callPackage,
12+ neovimUtils,
13+ perl,
14+ lndir,
15+ vimUtils,
16}:
1718neovim-unwrapped:
···21 # inherit interpreter from neovim
22 lua = neovim-unwrapped.lua;
2324+ wrapper =
25+ {
26+ extraName ? "",
27+ # certain plugins need a custom configuration (available in passthru.initLua)
28+ # to work with nix.
29+ # if true, the wrapper automatically appends those snippets when necessary
30+ autoconfigure ? true,
3132+ # append to PATH runtime deps of plugins
33+ autowrapRuntimeDeps ? true,
3435+ # should contain all args but the binary. Can be either a string or list
36+ wrapperArgs ? [ ],
37+ withPython2 ? false,
38+ withPython3 ? true,
39+ # the function you would have passed to python3.withPackages
40+ extraPython3Packages ? (_: [ ]),
4142+ withNodeJs ? false,
43+ withPerl ? false,
44+ withRuby ? true,
4546+ # wether to create symlinks in $out/bin/vi(m) -> $out/bin/nvim
47+ vimAlias ? false,
48+ viAlias ? false,
4950+ # additional argument not generated by makeNeovimConfig
51+ # it will append "-u <customRc>" to the wrapped arguments
52+ # set to false if you want to control where to save the generated config
53+ # (e.g., in ~/.config/init.vim or project/.nvimrc)
54+ wrapRc ? true,
55+ # vimL code that should be sourced as part of the generated init.lua file
56+ neovimRcContent ? null,
57+ # lua code to put into the generated init.lua file
58+ luaRcContent ? "",
59+ # DEPRECATED: entry to load in packpath
60+ # use 'plugins' instead
61+ packpathDirs ? null, # not used anymore
6263+ # a list of neovim plugin derivations, for instance
64+ # plugins = [
65+ # { plugin=far-vim; config = "let g:far#source='rg'"; optional = false; }
66+ # ]
67+ plugins ? [ ],
68+ ...
69+ }@attrs:
70+ assert
71+ withPython2
72+ -> throw "Python2 support has been removed from the neovim wrapper, please remove withPython2 and python2Env.";
7374+ assert
75+ packpathDirs != null
76+ -> throw "packpathdirs is not used anymore: pass a list of neovim plugin derivations in 'plugins' instead.";
7778+ stdenv.mkDerivation (
79+ finalAttrs:
80+ let
81+ pluginsNormalized = neovimUtils.normalizePlugins finalAttrs.plugins;
8283+ myVimPackage = neovimUtils.normalizedPluginsToVimPackage pluginsNormalized;
8485+ rubyEnv = bundlerEnv {
86+ name = "neovim-ruby-env";
87+ gemdir = ./ruby_provider;
88+ postBuild = ''
89+ ln -sf ${ruby}/bin/* $out/bin
90+ '';
91+ };
9293+ pluginRC = lib.foldl (
94+ acc: p: if p.config != null then acc ++ [ p.config ] else acc
95+ ) [ ] pluginsNormalized;
9697+ # a limited RC script used only to generate the manifest for remote plugins
98+ manifestRc = "";
99+ # we call vimrcContent without 'packages' to avoid the init.vim generation
100+ neovimRcContent' = lib.concatStringsSep "\n" (
101+ pluginRC ++ lib.optional (neovimRcContent != null) neovimRcContent
102+ );
103104+ packpathDirs.myNeovimPackages = myVimPackage;
105+ finalPackdir = neovimUtils.packDir packpathDirs;
106107+ luaPluginRC =
108+ let
109+ op =
110+ acc: normalizedPlugin:
111+ acc
112+ ++ lib.optional (
113+ finalAttrs.autoconfigure && normalizedPlugin.plugin.passthru ? initLua
114+ ) normalizedPlugin.plugin.passthru.initLua;
115+ in
116+ lib.foldl' op [ ] pluginsNormalized;
117118+ rcContent =
119+ ''
120+ ${luaRcContent}
121+ ''
122+ + lib.optionalString (neovimRcContent' != null) ''
123+ vim.cmd.source "${writeText "init.vim" neovimRcContent'}"
124+ ''
125+ + lib.concatStringsSep "\n" luaPluginRC;
126127+ getDeps = attrname: map (plugin: plugin.${attrname} or (_: [ ]));
128129+ requiredPlugins = vimUtils.requiredPluginsForPackage myVimPackage;
130+ pluginPython3Packages = getDeps "python3Dependencies" requiredPlugins;
131132+ python3Env =
133+ lib.warnIf (attrs ? python3Env)
134+ "Pass your python packages via the `extraPython3Packages`, e.g., `extraPython3Packages = ps: [ ps.pandas ]`"
135+ python3.pkgs.python.withPackages
136+ (ps: [ ps.pynvim ] ++ (extraPython3Packages ps) ++ (lib.concatMap (f: f ps) pluginPython3Packages));
137138+ wrapperArgsStr = if lib.isString wrapperArgs then wrapperArgs else lib.escapeShellArgs wrapperArgs;
139140+ generatedWrapperArgs =
141+ [
142+ # vim accepts a limited number of commands so we join all the provider ones
143+ "--add-flags"
144+ ''--cmd "lua ${providerLuaRc}"''
145+ ]
146+ ++
147+ lib.optionals
148+ (
149+ finalAttrs.packpathDirs.myNeovimPackages.start != [ ]
150+ || finalAttrs.packpathDirs.myNeovimPackages.opt != [ ]
151+ )
152+ [
153+ "--add-flags"
154+ ''--cmd "set packpath^=${finalPackdir}"''
155+ "--add-flags"
156+ ''--cmd "set rtp^=${finalPackdir}"''
157+ ]
158+ ++ lib.optionals finalAttrs.withRuby [
159+ "--set"
160+ "GEM_HOME"
161+ "${rubyEnv}/${rubyEnv.ruby.gemPath}"
162+ ]
163+ ++ lib.optionals (finalAttrs.runtimeDeps != [ ]) [
164+ "--suffix"
165+ "PATH"
166+ ":"
167+ (lib.makeBinPath finalAttrs.runtimeDeps)
168+ ];
169170+ providerLuaRc = neovimUtils.generateProviderRc {
171+ inherit (finalAttrs)
172+ withPython3
173+ withNodeJs
174+ withPerl
175+ withRuby
00000000176 ;
177+ };
0000000000000000000000000178179+ # If `configure` != {}, we can't generate the rplugin.vim file with e.g
180+ # NVIM_SYSTEM_RPLUGIN_MANIFEST *and* NVIM_RPLUGIN_MANIFEST env vars set in
181+ # the wrapper. That's why only when `configure` != {} (tested both here and
182+ # when `postBuild` is evaluated), we call makeWrapper once to generate a
183+ # wrapper with most arguments we need, excluding those that cause problems to
184+ # generate rplugin.vim, but still required for the final wrapper.
185+ finalMakeWrapperArgs =
186+ [
187+ "${neovim-unwrapped}/bin/nvim"
188+ "${placeholder "out"}/bin/nvim"
189+ ]
190+ ++ [
191+ "--set"
192+ "NVIM_SYSTEM_RPLUGIN_MANIFEST"
193+ "${placeholder "out"}/rplugin.vim"
194+ ]
195+ ++ lib.optionals finalAttrs.wrapRc [
196+ "--add-flags"
197+ "-u ${writeText "init.lua" rcContent}"
198+ ]
199+ ++ finalAttrs.generatedWrapperArgs;
200201+ perlEnv = perl.withPackages (p: [
202+ p.NeovimExt
203+ p.Appcpanminus
204+ ]);
205206+ pname = "neovim";
207+ version = lib.getVersion neovim-unwrapped;
0208 in
209+ {
210+ name = "${pname}-${version}${extraName}";
211+ inherit pname version;
212+ inherit plugins;
213+214+ __structuredAttrs = true;
215+ dontUnpack = true;
216+ inherit
217+ viAlias
218+ vimAlias
219+ withNodeJs
220+ withPython3
221+ withPerl
222+ withRuby
223 ;
224+ inherit
225+ autoconfigure
226+ autowrapRuntimeDeps
227+ wrapRc
228+ providerLuaRc
229+ packpathDirs
230+ ;
231+ inherit python3Env rubyEnv;
232+ inherit wrapperArgs generatedWrapperArgs;
233234+ runtimeDeps =
235+ let
236+ op = acc: normalizedPlugin: acc ++ normalizedPlugin.plugin.runtimeDeps or [ ];
237+ runtimeDeps = lib.foldl' op [ ] pluginsNormalized;
238+ in
239+ lib.optional finalAttrs.withRuby rubyEnv
240+ ++ lib.optional finalAttrs.withNodeJs nodejs
241+ ++ lib.optionals finalAttrs.autowrapRuntimeDeps runtimeDeps;
242243+ luaRcContent = rcContent;
244+ # Remove the symlinks created by symlinkJoin which we need to perform
245+ # extra actions upon
246+ postBuild =
247+ lib.optionalString stdenv.hostPlatform.isLinux ''
248+ rm $out/share/applications/nvim.desktop
249+ substitute ${neovim-unwrapped}/share/applications/nvim.desktop $out/share/applications/nvim.desktop \
250+ --replace-warn 'Name=Neovim' 'Name=Neovim wrapper'
251+ ''
252+ + lib.optionalString finalAttrs.withPython3 ''
253+ makeWrapper ${python3Env.interpreter} $out/bin/nvim-python3 --unset PYTHONPATH --unset PYTHONSAFEPATH
254+ ''
255+ + lib.optionalString (finalAttrs.withRuby) ''
256+ ln -s ${finalAttrs.rubyEnv}/bin/neovim-ruby-host $out/bin/nvim-ruby
257+ ''
258+ + lib.optionalString finalAttrs.withNodeJs ''
259+ ln -s ${neovim-node-client}/bin/neovim-node-host $out/bin/nvim-node
260+ ''
261+ + lib.optionalString finalAttrs.withPerl ''
262+ ln -s ${perlEnv}/bin/perl $out/bin/nvim-perl
263+ ''
264+ + lib.optionalString finalAttrs.vimAlias ''
265+ ln -s $out/bin/nvim $out/bin/vim
266+ ''
267+ + lib.optionalString finalAttrs.viAlias ''
268+ ln -s $out/bin/nvim $out/bin/vi
269+ ''
270+ + lib.optionalString (manifestRc != null) (
271+ let
272+ manifestWrapperArgs = [
273+ "${neovim-unwrapped}/bin/nvim"
274+ "${placeholder "out"}/bin/nvim-wrapper"
275+ ] ++ finalAttrs.generatedWrapperArgs;
276+ in
277+ ''
278+ echo "Generating remote plugin manifest"
279+ export NVIM_RPLUGIN_MANIFEST=$out/rplugin.vim
280+ makeWrapper ${lib.escapeShellArgs manifestWrapperArgs} ${wrapperArgsStr}
281282+ # Some plugins assume that the home directory is accessible for
283+ # initializing caches, temporary files, etc. Even if the plugin isn't
284+ # actively used, it may throw an error as soon as Neovim is launched
285+ # (e.g., inside an autoload script), causing manifest generation to
286+ # fail. Therefore, let's create a fake home directory before generating
287+ # the manifest, just to satisfy the needs of these plugins.
288+ #
289+ # See https://github.com/Yggdroot/LeaderF/blob/v1.21/autoload/lfMru.vim#L10
290+ # for an example of this behavior.
291+ export HOME="$(mktemp -d)"
292+ # Launch neovim with a vimrc file containing only the generated plugin
293+ # code. Pass various flags to disable temp file generation
294+ # (swap/viminfo) and redirect errors to stderr.
295+ # Only display the log on error since it will contain a few normally
296+ # irrelevant messages.
297+ if ! $out/bin/nvim-wrapper \
298+ -u ${writeText "manifest.vim" manifestRc} \
299+ -i NONE -n \
300+ -V1rplugins.log \
301+ +UpdateRemotePlugins +quit! > outfile 2>&1; then
302+ cat outfile
303+ echo -e "\nGenerating rplugin.vim failed!"
304+ exit 1
305+ fi
306+ rm "${placeholder "out"}/bin/nvim-wrapper"
307+ ''
308+ )
309+ + ''
310+ rm $out/bin/nvim
311+ touch $out/rplugin.vim
312313+ echo "Looking for lua dependencies..."
314+ source ${lua}/nix-support/utils.sh
315316+ _addToLuaPath "${finalPackdir}"
317318+ echo "LUA_PATH towards the end of packdir: $LUA_PATH"
319320+ makeWrapper ${lib.escapeShellArgs finalMakeWrapperArgs} ${wrapperArgsStr} \
321+ --prefix LUA_PATH ';' "$LUA_PATH" \
322+ --prefix LUA_CPATH ';' "$LUA_CPATH"
323+ '';
324325+ buildPhase = ''
326+ runHook preBuild
327+ mkdir -p $out
328+ for i in ${neovim-unwrapped}; do
329+ lndir -silent $i $out
330+ done
331+ runHook postBuild
332+ '';
333334+ preferLocalBuild = true;
335336+ nativeBuildInputs = [
337+ makeWrapper
338+ lndir
339+ ];
340341+ # A Vim "package", see ':h packages'
342+ vimPackage = myVimPackage;
343344+ checkPhase = ''
345+ runHook preCheck
346347+ $out/bin/nvim -i NONE -e +quitall!
348+ runHook postCheck
349+ '';
350351+ passthru = {
352+ inherit providerLuaRc packpathDirs;
353+ unwrapped = neovim-unwrapped;
354+ initRc = neovimRcContent';
355356+ tests = callPackage ./tests {
357+ };
358+ };
359360+ meta = {
361+ inherit (neovim-unwrapped.meta)
362+ description
363+ longDescription
364+ homepage
365+ mainProgram
366+ license
367+ maintainers
368+ platforms
369+ ;
370371+ # To prevent builds on hydra
372+ hydraPlatforms = [ ];
373+ # prefer wrapper over the package
374+ priority = (neovim-unwrapped.meta.priority or lib.meta.defaultPriority) - 1;
375+ };
376+ }
377+ );
378in
379+lib.makeOverridable wrapper
···21 applyPatches,
22}:
23let
24- version = "4.0.12.2823";
25 # The dotnet8 compatibility patches also change `yarn.lock`, so we must pass
26 # the already patched lockfile to `fetchYarnDeps`.
27 src = applyPatches {
···29 owner = "Sonarr";
30 repo = "Sonarr";
31 tag = "v${version}";
32- hash = "sha256-gAvbA3Idx73QEDthLwrM8Jbt6YhXxK8LzEJI6eF2k20=";
33 };
34 patches =
35 [
···21 applyPatches,
22}:
23let
24+ version = "4.0.13.2932";
25 # The dotnet8 compatibility patches also change `yarn.lock`, so we must pass
26 # the already patched lockfile to `fetchYarnDeps`.
27 src = applyPatches {
···29 owner = "Sonarr";
30 repo = "Sonarr";
31 tag = "v${version}";
32+ hash = "sha256-BR7CU8q+L2CY2UqR9n0cbX9R7ergzRPPvSrLl7Cn7EU=";
33 };
34 patches =
35 [
+2-1
pkgs/by-name/so/sonarr/update.py
···116 old_source_hash: new_source_hash,
117 })
118119- # We need access to the patched and updated src to get the patched `yarn.lock`.
0120 patched_src = os.path.join(work_dir, "patched-src")
121 subprocess.run(
122 [
···116 old_source_hash: new_source_hash,
117 })
118119+ # We need access to the patched and updated src to get the patched
120+ # `yarn.lock`.
121 patched_src = os.path.join(work_dir, "patched-src")
122 subprocess.run(
123 [