diff --git a/doc/release-notes/rl-2605.section.md b/doc/release-notes/rl-2605.section.md index f2db1dfb2769..65e3d7ae270b 100644 --- a/doc/release-notes/rl-2605.section.md +++ b/doc/release-notes/rl-2605.section.md @@ -272,7 +272,7 @@ gnuradioMinimal.override { - `mold` is now wrapped by default. -- `neovim` now disables by default the `python3` and `ruby` providers, unused by most users and reducing closure size from 365MiB to 240MiB. +- `neovim` now disables by default the `python3` and `ruby` providers, unused by most users and reducing closure size from 365MiB to 240MiB. Host provider executables are not exposed anymore along with the neovim wrapper. You can still refer to those using the neovim provider variables (e.g., `python3_host_prog`). ### Deprecations {#sec-nixpkgs-release-26.05-lib-deprecations} diff --git a/pkgs/applications/editors/neovim/wrapper.nix b/pkgs/applications/editors/neovim/wrapper.nix index 5234ad484c41..5fba635a2c48 100644 --- a/pkgs/applications/editors/neovim/wrapper.nix +++ b/pkgs/applications/editors/neovim/wrapper.nix @@ -15,6 +15,7 @@ perl, lndir, vimUtils, + runCommand, }: neovim-unwrapped: @@ -154,14 +155,33 @@ let (lib.makeBinPath finalAttrs.runtimeDeps) ]; - providerLuaRc = neovimUtils.generateProviderRc { - inherit (finalAttrs) - withPython3 - withNodeJs - withPerl - withRuby - ; - }; + providerLuaRc = + let + hostPython3 = + runCommand "nvim-host-${python3Env.name}" + { + nativeBuildInputs = [ + makeWrapper + ]; + } + '' + makeWrapper ${python3Env.interpreter} $out/bin/nvim-python3 --unset PYTHONPATH --unset PYTHONSAFEPATH + ''; + + genProviderCommand = + prog: withProg: exec: + if withProg then + "vim.g.${prog}_host_prog='${exec}'" + else + # speeds up neovim by bypassing provider discovery + "vim.g.loaded_${prog}_provider=0"; + in + lib.concatStringsSep ";" [ + (genProviderCommand "node" finalAttrs.withNodeJs "${neovim-node-client}/bin/neovim-node-host") + (genProviderCommand "perl" finalAttrs.withPerl "${perlEnv}/bin/perl") + (genProviderCommand "ruby" finalAttrs.withRuby "${finalAttrs.rubyEnv}/bin/neovim-ruby-host") + (genProviderCommand "python3" finalAttrs.withPython3 "${hostPython3}/bin/nvim-python3") + ]; # If `configure` != {}, we can't generate the rplugin.vim file with e.g # NVIM_SYSTEM_RPLUGIN_MANIFEST *and* NVIM_RPLUGIN_MANIFEST env vars set in @@ -236,18 +256,6 @@ let substitute ${neovim-unwrapped}/share/applications/nvim.desktop $out/share/applications/nvim.desktop \ --replace-warn 'Name=Neovim' 'Name=Neovim wrapper' '' - + lib.optionalString finalAttrs.withPython3 '' - makeWrapper ${python3Env.interpreter} $out/bin/nvim-python3 --unset PYTHONPATH --unset PYTHONSAFEPATH - '' - + lib.optionalString (finalAttrs.withRuby) '' - ln -s ${finalAttrs.rubyEnv}/bin/neovim-ruby-host $out/bin/nvim-ruby - '' - + lib.optionalString finalAttrs.withNodeJs '' - ln -s ${neovim-node-client}/bin/neovim-node-host $out/bin/nvim-node - '' - + lib.optionalString finalAttrs.withPerl '' - ln -s ${perlEnv}/bin/perl $out/bin/nvim-perl - '' + lib.optionalString finalAttrs.vimAlias '' ln -s $out/bin/nvim $out/bin/vim ''