From 390ca00b5b2d6fa4b2fd16bcfe3550f27b7a0021 Mon Sep 17 00:00:00 2001 From: "Matthieu C." <886074+teto@users.noreply.github.com> Date: Wed, 12 Jun 2024 15:07:03 +0200 Subject: [PATCH] neovimUtils.packDir: init: extend vimUtils.packDir in order for neovim to catch plugins dependencies, we fork vimUtils.packDir as `neovimUtils.packDir` to merge the various plugins nix-support/propagated-build-inputs files in the packDir derivation $out/nix-support/propagated-build-inputs where there was previously none. Having a fork allows us to experiment without impacting vim plugins. Once we are more confident this doesn't break stuff and/or the implementation is final, we can merge the fork back or replace one by the other. --- pkgs/applications/editors/neovim/utils.nix | 24 ++++++++++++++++++++ pkgs/applications/editors/neovim/wrapper.nix | 11 ++++++--- 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/pkgs/applications/editors/neovim/utils.nix b/pkgs/applications/editors/neovim/utils.nix index 8f9a5b880032..902d62d9486a 100644 --- a/pkgs/applications/editors/neovim/utils.nix +++ b/pkgs/applications/editors/neovim/utils.nix @@ -229,12 +229,36 @@ let ln -s ${grammar}/parser $out/parser/${name}.so ''); + /* + Fork of vimUtils.packDir that additionnally generates a propagated-build-inputs-file that + can be used by the lua hooks to generate a proper LUA_PATH + + Generates a packpath folder as expected by vim + Example: + packDir ( {myVimPackage = { start = [ vimPlugins.vim-fugitive ]; opt = []; }; }) + => "/nix/store/xxxxx-pack-dir" + */ + packDir = packages: + let + rawPackDir = vimUtils.packDir packages; + + in + rawPackDir.override ({ + postBuild = '' + mkdir $out/nix-support + for i in $(find -L $out -name propagated-build-inputs ); do + cat "$i" >> $out/nix-support/propagated-build-inputs + done + '';}); + + in { inherit makeNeovimConfig; inherit generateProviderRc; inherit legacyWrapper; inherit grammarToPlugin; + inherit packDir; inherit buildNeovimPlugin; buildNeovimPluginFrom2Nix = lib.warn "buildNeovimPluginFrom2Nix was renamed to buildNeovimPlugin" buildNeovimPlugin; diff --git a/pkgs/applications/editors/neovim/wrapper.nix b/pkgs/applications/editors/neovim/wrapper.nix index e877f1e1f764..14d5c51319f5 100644 --- a/pkgs/applications/editors/neovim/wrapper.nix +++ b/pkgs/applications/editors/neovim/wrapper.nix @@ -24,6 +24,8 @@ let , withNodeJs ? false , withPerl ? false , rubyEnv ? null + + # wether to create symlinks in $out/bin/vi(m) -> $out/bin/nvim , vimAlias ? false , viAlias ? false @@ -45,6 +47,8 @@ let stdenv.mkDerivation (finalAttrs: let + finalPackdir = neovimUtils.packDir packpathDirs; + rcContent = '' ${luaRcContent} '' + lib.optionalString (!isNull neovimRcContent) '' @@ -58,9 +62,10 @@ let [ "--add-flags" ''--cmd "lua ${providerLuaRc}"'' # (lib.intersperse "|" hostProviderViml) - ] ++ lib.optionals (packpathDirs.myNeovimPackages.start != [] || packpathDirs.myNeovimPackages.opt != []) [ - "--add-flags" ''--cmd "set packpath^=${vimUtils.packDir packpathDirs}"'' - "--add-flags" ''--cmd "set rtp^=${vimUtils.packDir packpathDirs}"'' + ] + ++ lib.optionals (packpathDirs.myNeovimPackages.start != [] || packpathDirs.myNeovimPackages.opt != []) [ + "--add-flags" ''--cmd "set packpath^=${finalPackdir}"'' + "--add-flags" ''--cmd "set rtp^=${finalPackdir}"'' ] ;