diff options
Diffstat (limited to 'nixpkgs/pkgs/applications/editors/neovim/wrapper.nix')
-rw-r--r-- | nixpkgs/pkgs/applications/editors/neovim/wrapper.nix | 60 |
1 files changed, 39 insertions, 21 deletions
diff --git a/nixpkgs/pkgs/applications/editors/neovim/wrapper.nix b/nixpkgs/pkgs/applications/editors/neovim/wrapper.nix index 66127980bf67..96b61a43cca0 100644 --- a/nixpkgs/pkgs/applications/editors/neovim/wrapper.nix +++ b/nixpkgs/pkgs/applications/editors/neovim/wrapper.nix @@ -3,8 +3,8 @@ , bundlerEnv, ruby , nodejs , nodePackages -, pythonPackages , python3Packages +, callPackage }: with lib; @@ -12,31 +12,45 @@ neovim: let wrapper = { - # should contain all args but the binary - wrapperArgs ? "" + extraName ? "" + # should contain all args but the binary. Can be either a string or list + , wrapperArgs ? [] , manifestRc ? null - , withPython2 ? true, python2Env ? null + , withPython2 ? false , withPython3 ? true, python3Env ? null , withNodeJs ? false , rubyEnv ? null , vimAlias ? false , viAlias ? false + + # additional argument not generated by makeNeovimConfig + # it will append "-u <customRc>" to the wrapped arguments + # set to false if you want to control where to save the generated config + # (e.g., in ~/.config/init.vim or project/.nvimrc) + , wrapRc ? true + , neovimRcContent ? "" , ... - }: + }@args: let - # 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 - # the wrapper. That's why only when configure != {} (tested both here and - # when postBuild is evaluated), we call makeWrapper once to generate a - # wrapper with most arguments we need, excluding those that cause problems to - # generate rplugin.vim, but still required for the final wrapper. - finalMakeWrapperArgs = - [ "${neovim}/bin/nvim" "${placeholder "out"}/bin/nvim" ] ++ - [ "--set" "NVIM_SYSTEM_RPLUGIN_MANIFEST" "${placeholder "out"}/rplugin.vim" ]; + wrapperArgsStr = if isString wrapperArgs then wrapperArgs else lib.escapeShellArgs wrapperArgs; + + # 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 + # the wrapper. That's why only when configure != {} (tested both here and + # when postBuild is evaluated), we call makeWrapper once to generate a + # wrapper with most arguments we need, excluding those that cause problems to + # generate rplugin.vim, but still required for the final wrapper. + finalMakeWrapperArgs = + [ "${neovim}/bin/nvim" "${placeholder "out"}/bin/nvim" ] + ++ [ "--set" "NVIM_SYSTEM_RPLUGIN_MANIFEST" "${placeholder "out"}/rplugin.vim" ] + ++ optionals wrapRc [ "--add-flags" "-u ${writeText "init.vim" neovimRcContent}" ] + ; in + assert withPython2 -> throw "Python2 support has been removed from the neovim wrapper, please remove withPython2 and python2Env."; + symlinkJoin { - name = "neovim-${lib.getVersion neovim}"; + name = "neovim-${lib.getVersion neovim}${extraName}"; # Remove the symlinks created by symlinkJoin which we need to perform # extra actions upon postBuild = lib.optionalString stdenv.isLinux '' @@ -44,9 +58,6 @@ let substitute ${neovim}/share/applications/nvim.desktop $out/share/applications/nvim.desktop \ --replace 'Name=Neovim' 'Name=WrappedNeovim' '' - + optionalString withPython2 '' - makeWrapper ${python2Env}/bin/python $out/bin/nvim-python --unset PYTHONPATH - '' + optionalString withPython3 '' makeWrapper ${python3Env}/bin/python3 $out/bin/nvim-python3 --unset PYTHONPATH '' @@ -68,7 +79,7 @@ let in '' echo "Generating remote plugin manifest" export NVIM_RPLUGIN_MANIFEST=$out/rplugin.vim - makeWrapper ${lib.escapeShellArgs manifestWrapperArgs} ${wrapperArgs} + makeWrapper ${lib.escapeShellArgs manifestWrapperArgs} ${wrapperArgsStr} # Some plugins assume that the home directory is accessible for # initializing caches, temporary files, etc. Even if the plugin isn't @@ -98,7 +109,8 @@ let '') + '' rm $out/bin/nvim - makeWrapper ${lib.escapeShellArgs finalMakeWrapperArgs} ${wrapperArgs} + touch $out/rplugin.vim + makeWrapper ${lib.escapeShellArgs finalMakeWrapperArgs} ${wrapperArgsStr} ''; paths = [ neovim ]; @@ -106,7 +118,13 @@ let preferLocalBuild = true; nativeBuildInputs = [ makeWrapper ]; - passthru = { unwrapped = neovim; }; + passthru = { + unwrapped = neovim; + initRc = neovimRcContent; + + tests = callPackage ./tests.nix { + }; + }; meta = neovim.meta // { # To prevent builds on hydra |