From 1fd1e81cdd865d60c726fff33b37e406652d1365 Mon Sep 17 00:00:00 2001 From: Nikita Rudenko Date: Thu, 16 Apr 2026 14:39:35 +0300 Subject: [PATCH] vimPlugins: remove redundant patches and replaceVars Some vimPlugins patches contain replacement of bare binary names to full nix store paths, i.e. replacing `"node"` with `"${pkgs.nodejs}/bin/node"` This is brittle and tedious in support, since any code motion in plugin may break such patch. Let's replace this with a `runtimeDeps` attribute, which lives outside of plugin code. --- .../editors/vim/plugins/overrides.nix | 55 ++++++++----------- .../vim/plugins/patches/aider-nvim/bin.patch | 15 ----- .../aw-watcher-vim/program_paths.patch | 13 ----- .../plugins/patches/gx-nvim/fix-paths.patch | 13 ----- .../fix-node-paths.patch | 31 ----------- .../patches/openscad.nvim/program_paths.patch | 8 --- .../vim/plugins/patches/peek-nvim/cmd.patch | 15 +---- .../hardcode-mdt-binary-path.patch | 22 -------- .../patches/ranger.nvim/fix-paths.patch | 31 ----------- 9 files changed, 23 insertions(+), 180 deletions(-) delete mode 100644 pkgs/applications/editors/vim/plugins/patches/aider-nvim/bin.patch delete mode 100644 pkgs/applications/editors/vim/plugins/patches/aw-watcher-vim/program_paths.patch delete mode 100644 pkgs/applications/editors/vim/plugins/patches/gx-nvim/fix-paths.patch delete mode 100644 pkgs/applications/editors/vim/plugins/patches/markdown-preview-nvim/fix-node-paths.patch delete mode 100644 pkgs/applications/editors/vim/plugins/patches/openscad.nvim/program_paths.patch delete mode 100644 pkgs/applications/editors/vim/plugins/patches/preview-nvim/hardcode-mdt-binary-path.patch delete mode 100644 pkgs/applications/editors/vim/plugins/patches/ranger.nvim/fix-paths.patch diff --git a/pkgs/applications/editors/vim/plugins/overrides.nix b/pkgs/applications/editors/vim/plugins/overrides.nix index c1e570868212..0bd552585b20 100644 --- a/pkgs/applications/editors/vim/plugins/overrides.nix +++ b/pkgs/applications/editors/vim/plugins/overrides.nix @@ -193,10 +193,8 @@ assertNoAdditions { }; aider-nvim = super.aider-nvim.overrideAttrs { - patches = [ - (replaceVars ./patches/aider-nvim/bin.patch { - aider = lib.getExe aider-chat; - }) + runtimeDeps = [ + aider-chat ]; }; @@ -243,10 +241,8 @@ assertNoAdditions { }; aw-watcher-vim = super.aw-watcher-vim.overrideAttrs { - patches = [ - (replaceVars ./patches/aw-watcher-vim/program_paths.patch { - curl = lib.getExe curl; - }) + runtimeDeps = [ + curl ]; }; @@ -1392,10 +1388,8 @@ assertNoAdditions { }; gx-nvim = super.gx-nvim.overrideAttrs { - patches = lib.optionals stdenv.hostPlatform.isLinux [ - (replaceVars ./patches/gx-nvim/fix-paths.patch { - inherit xdg-utils; - }) + runtimeDeps = [ + xdg-utils ]; nvimRequireCheck = "gx"; @@ -1932,10 +1926,8 @@ assertNoAdditions { }; in super.markdown-preview-nvim.overrideAttrs { - patches = [ - (replaceVars ./patches/markdown-preview-nvim/fix-node-paths.patch { - node = "${nodejs}/bin/node"; - }) + runtimeDeps = [ + nodejs ]; postInstall = '' cp -r ${nodeDep} $out/app/node_modules @@ -2975,6 +2967,10 @@ assertNoAdditions { # The plugin depends on either skim-vim or fzf-vim, but we don't want to force the user so we # avoid choosing one of them and leave it to the user openscad-nvim = super.openscad-nvim.overrideAttrs { + runtimeDeps = [ + openscad + ]; + buildInputs = [ zathura openscad @@ -2986,11 +2982,6 @@ assertNoAdditions { "openscad.snippets.openscad" "openscad.utilities" ]; - patches = [ - (replaceVars ./patches/openscad.nvim/program_paths.patch { - openscad = lib.getExe openscad; - }) - ]; }; org-notebook-nvim = super.org-notebook-nvim.overrideAttrs { @@ -3075,12 +3066,14 @@ assertNoAdditions { }; peek-nvim = super.peek-nvim.overrideAttrs (old: { + runtimeDeps = [ + deno + ]; + patches = [ # Patch peek-nvim to run using nixpkgs deno # This means end-users have to build peek-nvim the first time they use it... - (replaceVars ./patches/peek-nvim/cmd.patch { - deno = lib.getExe deno; - }) + ./patches/peek-nvim/cmd.patch ]; }); @@ -3125,10 +3118,8 @@ assertNoAdditions { }; Preview-nvim = super.Preview-nvim.overrideAttrs { - patches = [ - (replaceVars ./patches/preview-nvim/hardcode-mdt-binary-path.patch { - mdt = lib.getExe md-tui; - }) + runtimeDeps = [ + md-tui ]; }; @@ -3195,11 +3186,9 @@ assertNoAdditions { }; ranger-nvim = super.ranger-nvim.overrideAttrs { - patches = [ ./patches/ranger.nvim/fix-paths.patch ]; - - postPatch = '' - substituteInPlace lua/ranger-nvim.lua --replace-fail '@ranger@' ${ranger}/bin/ranger - ''; + runtimeDeps = [ + ranger + ]; }; refactoring-nvim = super.refactoring-nvim.overrideAttrs { diff --git a/pkgs/applications/editors/vim/plugins/patches/aider-nvim/bin.patch b/pkgs/applications/editors/vim/plugins/patches/aider-nvim/bin.patch deleted file mode 100644 index 269c588cb6fc..000000000000 --- a/pkgs/applications/editors/vim/plugins/patches/aider-nvim/bin.patch +++ /dev/null @@ -1,15 +0,0 @@ -diff --git a/lua/aider.lua b/lua/aider.lua -index 98b5071..589b06d 100644 ---- a/lua/aider.lua -+++ b/lua/aider.lua -@@ -61,9 +61,9 @@ function M.AiderOpen(args, window_type) - log("Existing aider buffer found, opening in new window") - helpers.open_buffer_in_new_window(window_type, M.aider_buf) - else - log("No existing aider buffer, creating new one") -- local command = "aider " .. (args or "") -+ local command = "@aider@ " .. (args or "") - log("Opening window with type: " .. window_type) - helpers.open_window(window_type) - log("Adding buffers to command") - command = helpers.add_buffers_to_command(command, is_valid_buffer) diff --git a/pkgs/applications/editors/vim/plugins/patches/aw-watcher-vim/program_paths.patch b/pkgs/applications/editors/vim/plugins/patches/aw-watcher-vim/program_paths.patch deleted file mode 100644 index 857327664108..000000000000 --- a/pkgs/applications/editors/vim/plugins/patches/aw-watcher-vim/program_paths.patch +++ /dev/null @@ -1,13 +0,0 @@ -diff --git a/plugin/activitywatch.vim b/plugin/activitywatch.vim -index 6986553..7462b02 100644 ---- a/plugin/activitywatch.vim -+++ b/plugin/activitywatch.vim -@@ -29,7 +29,7 @@ let s:heartbeat_apiurl = printf('%s/heartbeat?pulsetime=30', s:bucket_apiurl) - let s:http_response_code = {} - - function! HTTPPostJson(url, data) -- let l:req = ['curl', '-s', a:url, -+ let l:req = ['@curl@', '-s', a:url, - \ '-H', 'Content-Type: application/json', - \ '-X', 'POST', - \ '-d', json_encode(a:data), diff --git a/pkgs/applications/editors/vim/plugins/patches/gx-nvim/fix-paths.patch b/pkgs/applications/editors/vim/plugins/patches/gx-nvim/fix-paths.patch deleted file mode 100644 index 380a32b4d54c..000000000000 --- a/pkgs/applications/editors/vim/plugins/patches/gx-nvim/fix-paths.patch +++ /dev/null @@ -1,13 +0,0 @@ -diff --git a/lua/gx/init.lua b/lua/gx/init.lua -index 12272d4..c51771a 100644 ---- a/lua/gx/init.lua -+++ b/lua/gx/init.lua -@@ -73,7 +73,7 @@ local function get_open_browser_app() - if sysname == "Darwin" then - app = "open" - elseif sysname == "Linux" then -- app = "xdg-open" -+ app = "@xdg-utils@/bin/xdg-open" - elseif sysname == "Windows_NT" then - app = "powershell.exe" - end diff --git a/pkgs/applications/editors/vim/plugins/patches/markdown-preview-nvim/fix-node-paths.patch b/pkgs/applications/editors/vim/plugins/patches/markdown-preview-nvim/fix-node-paths.patch deleted file mode 100644 index ec2408d6f4a8..000000000000 --- a/pkgs/applications/editors/vim/plugins/patches/markdown-preview-nvim/fix-node-paths.patch +++ /dev/null @@ -1,31 +0,0 @@ -diff --git a/autoload/health/mkdp.vim b/autoload/health/mkdp.vim -index 323b57b..8053ea8 100644 ---- a/autoload/health/mkdp.vim -+++ b/autoload/health/mkdp.vim -@@ -8,8 +8,8 @@ function! health#mkdp#check() abort - lua vim.health.info('Pre build: ' .. vim.api.nvim_eval('l:mkdp_server_script')) - lua vim.health.info('Pre build version: ' .. vim.fn['mkdp#util#pre_build_version']()) - lua vim.health.ok('Using pre build') -- elseif executable('node') -- lua vim.health.info('Node version: ' .. string.gsub(vim.fn.system('node --version'), '^%s*(.-)%s*$', '%1')) -+ else -+ lua vim.health.info('Node version: ' .. string.gsub(vim.fn.system('@node@ --version'), '^%s*(.-)%s*$', '%1')) - let l:mkdp_server_script = s:mkdp_root_dir .. '/app/server.js' - lua vim.health.info('Script: ' .. vim.api.nvim_eval('l:mkdp_server_script')) - lua vim.health.info('Script exists: ' .. vim.fn.filereadable(vim.api.nvim_eval('l:mkdp_server_script'))) -diff --git a/autoload/mkdp/rpc.vim b/autoload/mkdp/rpc.vim -index b257571..57f04e7 100644 ---- a/autoload/mkdp/rpc.vim -+++ b/autoload/mkdp/rpc.vim -@@ -41,9 +41,9 @@ function! mkdp#rpc#start_server() abort - let l:mkdp_server_script = s:mkdp_root_dir . '/app/bin/markdown-preview-' . mkdp#util#get_platform() - if executable(l:mkdp_server_script) - let l:cmd = [l:mkdp_server_script, '--path', s:mkdp_root_dir . '/app/server.js'] -- elseif executable('node') -+ else - let l:mkdp_server_script = s:mkdp_root_dir . '/app/index.js' -- let l:cmd = ['node', l:mkdp_server_script, '--path', s:mkdp_root_dir . '/app/server.js'] -+ let l:cmd = ['@node@', l:mkdp_server_script, '--path', s:mkdp_root_dir . '/app/server.js'] - endif - if exists('l:cmd') - if s:is_vim diff --git a/pkgs/applications/editors/vim/plugins/patches/openscad.nvim/program_paths.patch b/pkgs/applications/editors/vim/plugins/patches/openscad.nvim/program_paths.patch deleted file mode 100644 index 8cc5d97f354e..000000000000 --- a/pkgs/applications/editors/vim/plugins/patches/openscad.nvim/program_paths.patch +++ /dev/null @@ -1,8 +0,0 @@ -diff --git a/lua/openscad.lua b/lua/openscad.lua -index f889463..dde5b97 100644 ---- a/lua/openscad.lua -+++ b/lua/openscad.lua -@@ -147 +147 @@ function M.exec_openscad() -- or 'openscad' -+ or '@openscad@' --- diff --git a/pkgs/applications/editors/vim/plugins/patches/peek-nvim/cmd.patch b/pkgs/applications/editors/vim/plugins/patches/peek-nvim/cmd.patch index 3c80e55e285b..f10c0e83b7ac 100644 --- a/pkgs/applications/editors/vim/plugins/patches/peek-nvim/cmd.patch +++ b/pkgs/applications/editors/vim/plugins/patches/peek-nvim/cmd.patch @@ -1,16 +1,3 @@ -diff --git a/app/src/main.ts b/app/src/main.ts -index c82d914..e8542f3 100644 ---- a/app/src/main.ts -+++ b/app/src/main.ts -@@ -73,7 +73,7 @@ async function init(socket: WebSocket) { - const onListen: Deno.ServeOptions['onListen'] = ({ hostname, port }) => { - const serverUrl = `${hostname.replace('0.0.0.0', 'localhost')}:${port}`; - logger.info(`listening on ${serverUrl}`); -- const webview = new Deno.Command('deno', { -+ const webview = new Deno.Command('@deno@', { - cwd: dirname(fromFileUrl(Deno.mainModule)), - args: [ - 'run', diff --git a/lua/peek/app.lua b/lua/peek/app.lua index af5148e..5e67563 100644 --- a/lua/peek/app.lua @@ -22,7 +9,7 @@ index af5148e..5e67563 100644 - 'deno', - 'task', - '--quiet', -+ '@deno@', ++ 'deno', 'run', + '--allow-read', + '--allow-write', diff --git a/pkgs/applications/editors/vim/plugins/patches/preview-nvim/hardcode-mdt-binary-path.patch b/pkgs/applications/editors/vim/plugins/patches/preview-nvim/hardcode-mdt-binary-path.patch deleted file mode 100644 index e8082f51c370..000000000000 --- a/pkgs/applications/editors/vim/plugins/patches/preview-nvim/hardcode-mdt-binary-path.patch +++ /dev/null @@ -1,22 +0,0 @@ -diff --git a/lua/preview.lua b/lua/preview.lua -index 6d9875d..729cc70 100644 ---- a/lua/preview.lua -+++ b/lua/preview.lua -@@ -28,7 +28,7 @@ local function open_window(file) - vim.env.MDT_WIDTH = width - - vim.cmd.vnew() -- vim.fn.termopen("mdt " .. file) -+ vim.fn.termopen("@mdt@ " .. file) - - vim.cmd("setlocal nonumber norelativenumber") - vim.api.nvim_feedkeys("a", "t", false) -@@ -49,7 +49,7 @@ end - function M.setup() - -- Check if "mdt" is installed - if vim.fn.executable("mdt") == 0 then -- install() -+ -- install() - end - - set_cmd() diff --git a/pkgs/applications/editors/vim/plugins/patches/ranger.nvim/fix-paths.patch b/pkgs/applications/editors/vim/plugins/patches/ranger.nvim/fix-paths.patch deleted file mode 100644 index b784c10387db..000000000000 --- a/pkgs/applications/editors/vim/plugins/patches/ranger.nvim/fix-paths.patch +++ /dev/null @@ -1,31 +0,0 @@ -diff --git a/lua/ranger-nvim.lua b/lua/ranger-nvim.lua -index be95e36..3bd1587 100644 ---- a/lua/ranger-nvim.lua -+++ b/lua/ranger-nvim.lua -@@ -127,7 +127,7 @@ local function build_ranger_cmd(select_current_file) - local selectfile_flag = select_current_file and " --selectfile=" .. selected_file or "" - if select_current_file then - return string.format( -- "ranger --choosefiles=%s %s %s", -+ "@ranger@ --choosefiles=%s %s %s", - SELECTED_FILEPATH, - selectfile_flag, - create_ranger_cmd_flags(create_cmd_values(opts.keybinds)) -@@ -135,7 +135,7 @@ local function build_ranger_cmd(select_current_file) - else - vim.api.nvim_buf_delete(1, { force = true }) - return string.format( -- "ranger --choosefiles=%s %s %s", -+ "@ranger@ --choosefiles=%s %s %s", - SELECTED_FILEPATH, - create_ranger_cmd_flags(create_cmd_values(opts.keybinds)), - get_absolute_argument() -@@ -209,7 +209,7 @@ end - ---Opens ranger and open selected files on exit. - ---@param select_current_file boolean|nil open ranger and select the current file. Defaults to true. - function M.open(select_current_file) -- if vim.fn.executable("ranger") ~= 1 then -+ if vim.fn.executable("@ranger@") ~= 1 then - vim.api.nvim_err_write( - "ranger executable not found, please check that ranger is installed and is in your path\n" - )