From 0ae3b043e9fb508472f2a9237e00ff027b65b080 Mon Sep 17 00:00:00 2001 From: teto <886074+teto@users.noreply.github.com> Date: Fri, 13 Mar 2026 15:37:09 +0100 Subject: [PATCH] neovimUtils.makeNeovimConfig: deprecate I am not sure why I introduced it, probably to avoid touching the wrapper interface too much and massage arguments beforehand. With the `finalAttrs` pattern, one can more easily override the resulting neovim derivation without having to preprocess arguments first so `makeNeovimConfig` just ends up making the interface more confusing. --- doc/release-notes/rl-2605.section.md | 2 +- .../editors/neovim/tests/default.nix | 22 +++-- pkgs/applications/editors/neovim/utils.nix | 81 ++++++++----------- pkgs/applications/editors/neovim/wrapper.nix | 1 - 4 files changed, 43 insertions(+), 63 deletions(-) diff --git a/doc/release-notes/rl-2605.section.md b/doc/release-notes/rl-2605.section.md index 54c1f3d750c5..b2c43bb439b7 100644 --- a/doc/release-notes/rl-2605.section.md +++ b/doc/release-notes/rl-2605.section.md @@ -259,7 +259,7 @@ - neovim lua dependencies are now set in the generated init.lua instead of modifying LUA_PATH in the wrapper. Commands run pre-vimrc via `nvim --cmd "require'LUA_MODULE'"` may - not find their lua dependencies anymore. Use `nvim -c "lua require'LUA_MODULE'"` instead to run these commands after loading `init.lua`. + not find their lua dependencies anymore. Use `nvim -c "lua require'LUA_MODULE'"` instead to run these commands after loading `init.lua`. If you use `wrapNeovim` with `wrapRc` set to `false`, you may lose the lua dependencies if you are not loading the generated `init.lua`. - We now use the upstream wrapper script for Gradle, supporting both the `JAVA_HOME` and `GRADLE_OPTS` environment variables. diff --git a/pkgs/applications/editors/neovim/tests/default.nix b/pkgs/applications/editors/neovim/tests/default.nix index 58be196ca1e1..0e5bdf7a5d07 100644 --- a/pkgs/applications/editors/neovim/tests/default.nix +++ b/pkgs/applications/editors/neovim/tests/default.nix @@ -43,27 +43,27 @@ let } ]; - nvimConfSingleLines = makeNeovimConfig { + nvimConfSingleLines = { plugins = packagesWithSingleLineConfigs; - customRC = '' + neovimRcContent = '' " just a comment ''; }; - nvimConfNix = makeNeovimConfig { + nvimConfNix = { inherit plugins; - customRC = '' + neovimRcContent = '' " just a comment ''; }; - nvim-with-luasnip = wrapNeovim2 "-with-luasnip" (makeNeovimConfig { + nvim-with-luasnip = wrapNeovim2 "-with-luasnip" { plugins = [ { plugin = vimPlugins.luasnip; } ]; - }); + }; # build should fail with a wrong nvim-run-failing-check = @@ -74,8 +74,6 @@ let doCheck = true; }; - nvimAutoDisableWrap = makeNeovimConfig { }; - wrapNeovim2 = suffix: config: wrapNeovimUnstable neovim-unwrapped ( @@ -308,15 +306,15 @@ pkgs.lib.recurseIntoAttrs rec { ''; # nixpkgs should detect that no wrapping is necessary - nvimShouldntWrap = wrapNeovim2 "-should-not-wrap" nvimAutoDisableWrap; + nvimShouldntWrap = wrapNeovim2 "-should-not-wrap" { }; # this will generate a neovimRc content but we disable wrapping - nvimDontWrap = wrapNeovim2 "-forced-nowrap" (makeNeovimConfig { + nvimDontWrap = wrapNeovim2 "-forced-nowrap" { wrapRc = false; - customRC = '' + neovimRcContent = '' " this shouldn't trigger the creation of an init.vim ''; - }); + }; force-nowrap = runTest nvimDontWrap '' ! grep -F -- ' -u' ${nvimDontWrap}/bin/nvim diff --git a/pkgs/applications/editors/neovim/utils.nix b/pkgs/applications/editors/neovim/utils.nix index 04d2ac2eb6b9..af180c869a73 100644 --- a/pkgs/applications/editors/neovim/utils.nix +++ b/pkgs/applications/editors/neovim/utils.nix @@ -146,45 +146,38 @@ let let luaEnv = neovim-unwrapped.lua.withPackages extraLuaPackages; in - attrs - // { - neovimRcContent = customRC; - luaRcContent = - if attrs ? luaRcContent then - lib.warn "makeNeovimConfig: luaRcContent parameter is deprecated. Please use customLuaRC instead." attrs.luaRcContent - else - customLuaRC; - wrapperArgs = lib.optionals (luaEnv != null) [ - "--prefix" - "LUA_PATH" - ";" - (neovim-unwrapped.lua.pkgs.luaLib.genLuaPathAbsStr luaEnv) - "--prefix" - "LUA_CPATH" - ";" - (neovim-unwrapped.lua.pkgs.luaLib.genLuaCPathAbsStr luaEnv) - ]; - }; + lib.warn + "neovimUtils.makeNeovimConfig is deprecated. Use wrapNeovim or wrapNeovimUnstable directly." + ( + attrs + // { + neovimRcContent = customRC; + luaRcContent = + if attrs ? luaRcContent then + lib.warn "makeNeovimConfig: luaRcContent parameter is deprecated. Please use customLuaRC instead." attrs.luaRcContent + else + customLuaRC; + wrapperArgs = lib.optionals (luaEnv != null) [ + "--prefix" + "LUA_PATH" + ";" + (neovim-unwrapped.lua.pkgs.luaLib.genLuaPathAbsStr luaEnv) + "--prefix" + "LUA_CPATH" + ";" + (neovim-unwrapped.lua.pkgs.luaLib.genLuaCPathAbsStr luaEnv) + ]; + } + ); # to keep backwards compatibility for people using neovim.override legacyWrapper = neovim: { extraMakeWrapperArgs ? "", - # the function you would have passed to python.withPackages - extraPythonPackages ? (_: [ ]), - # the function you would have passed to python.withPackages - withPython3 ? false, - extraPython3Packages ? (_: [ ]), - # the function you would have passed to lua.withPackages - extraLuaPackages ? (_: [ ]), - withNodeJs ? false, - withRuby ? false, - vimAlias ? false, - viAlias ? false, configure ? { }, - extraName ? "", - }: + ... + }@attrs: let # we convert from the old configure.format to @@ -205,26 +198,16 @@ let optional = true; }) opt); - res = makeNeovimConfig { - inherit withPython3; - inherit extraPython3Packages; - inherit extraLuaPackages; - inherit - withNodeJs - withRuby - viAlias - vimAlias - ; - customRC = configure.customRC or ""; - customLuaRC = configure.customLuaRC or ""; - inherit plugins; - inherit extraName; - }; in wrapNeovimUnstable neovim ( - res + attrs // { - wrapperArgs = lib.escapeShellArgs res.wrapperArgs + " " + extraMakeWrapperArgs; + neovimRcContent = configure.customRC or ""; + luaRcContent = configure.customLuaRC or ""; + inherit plugins; + + wrapperArgs = lib.escapeShellArgs (attrs.wrapperArgs or [ ]) + " " + extraMakeWrapperArgs; + wrapRc = configure != { }; legacyWrapper = true; } diff --git a/pkgs/applications/editors/neovim/wrapper.nix b/pkgs/applications/editors/neovim/wrapper.nix index a0d60ffc551e..723f608c3f40 100644 --- a/pkgs/applications/editors/neovim/wrapper.nix +++ b/pkgs/applications/editors/neovim/wrapper.nix @@ -51,7 +51,6 @@ let vimAlias ? false, viAlias ? false, - # additional argument not generated by makeNeovimConfig # it sets the VIMINIT environment variable to "lua dofile('${customRc}')" # set to false if you want to control where to save the generated config # (e.g., in ~/.config/init.vim or project/.nvimrc)