diff --git a/pkgs/misc/vim-plugins/build-vim-plugin.nix b/pkgs/misc/vim-plugins/build-vim-plugin.nix index 3c623f08a169..a3a09a93ac9c 100644 --- a/pkgs/misc/vim-plugins/build-vim-plugin.nix +++ b/pkgs/misc/vim-plugins/build-vim-plugin.nix @@ -1,6 +1,7 @@ { lib, stdenv -, rtpPath ? "share/vim-plugins" +, rtpPath , vim +, vimGenDocHook }: rec { @@ -25,6 +26,7 @@ rec { addRtp "${rtpPath}/${path}" attrs (stdenv.mkDerivation (attrs // { name = namePrefix + name; + nativeBuildInputs = attrs.nativeBuildInputs or [] ++ [ vimGenDocHook ]; inherit unpackPhase configurePhase buildPhase addonInfo preInstall postInstall; installPhase = '' @@ -34,21 +36,6 @@ rec { mkdir -p $out/${rtpPath} cp -r . $target - # build help tags - if [ -d "$target/doc" ]; then - echo "Building help tags" - if ! ${vim}/bin/vim -N -u NONE -i NONE -n -E -s -V1 -c "helptags $target/doc" +quit!; then - echo "Failed to build help tags!" - exit 1 - fi - else - echo "No docs available" - fi - - if [ -n "$addonInfo" ]; then - echo "$addonInfo" > $target/addon-info.json - fi - runHook postInstall ''; })); diff --git a/pkgs/misc/vim-plugins/default.nix b/pkgs/misc/vim-plugins/default.nix index b56dced89717..9bfcf4431863 100644 --- a/pkgs/misc/vim-plugins/default.nix +++ b/pkgs/misc/vim-plugins/default.nix @@ -3,7 +3,7 @@ let - inherit (vimUtils.override {inherit vim;}) buildVimPluginFrom2Nix; + inherit (vimUtils.override {inherit vim;}) buildVimPluginFrom2Nix vimGenDocHook; inherit (lib) extends; @@ -11,6 +11,8 @@ let # Convert derivation to a vim plugin. toVimPlugin = drv: drv.overrideAttrs(oldAttrs: { + + nativeBuildInputs = oldAttrs.nativeBuildInputs or [] ++ [ vimGenDocHook ]; passthru = (oldAttrs.passthru or {}) // { vimPlugin = true; }; diff --git a/pkgs/misc/vim-plugins/update-shell.nix b/pkgs/misc/vim-plugins/update-shell.nix new file mode 100644 index 000000000000..e95801624b69 --- /dev/null +++ b/pkgs/misc/vim-plugins/update-shell.nix @@ -0,0 +1,13 @@ +{ nixpkgs ? import ../../.. { } }: +with nixpkgs; +let + pyEnv = python3.withPackages(ps: [ ps.GitPython ]); +in +mkShell { + packages = [ + bash + pyEnv + nix-prefetch-scripts + ]; +} + diff --git a/pkgs/misc/vim-plugins/update.py b/pkgs/misc/vim-plugins/update.py index 126b0d3e7d8d..fa80b58eb386 100755 --- a/pkgs/misc/vim-plugins/update.py +++ b/pkgs/misc/vim-plugins/update.py @@ -1,5 +1,6 @@ #!/usr/bin/env nix-shell -#!nix-shell -p nix-prefetch-git -p python3 -p python3Packages.GitPython nix -i python3 +#!nix-shell update-shell.nix -i python3 + # format: # $ nix run nixpkgs.python3Packages.black -c black update.py diff --git a/pkgs/misc/vim-plugins/vim-gen-doc-hook.sh b/pkgs/misc/vim-plugins/vim-gen-doc-hook.sh new file mode 100644 index 000000000000..0efc62912013 --- /dev/null +++ b/pkgs/misc/vim-plugins/vim-gen-doc-hook.sh @@ -0,0 +1,31 @@ +echo "Sourcing vim-gen-doc-hook" + +# the doc folder is copied via the copy_directories entry of the rockspec +# in the folder gitsigns.nvim-scm-1-rocks/gitsigns.nvim/scm-1 +vimPluginGenTags() { + echo "Executing vimPluginGenTags" + + target="$out/@rtpPath@/$pname" + mkdir -p $out/@rtpPath@ + cp -r . $target + + # build help tags + if [ -d "$target/doc" ]; then + echo "Building help tags" + if ! @vimBinary@ -N -u NONE -i NONE -n -E -s -V1 -c "helptags $target/doc" +quit!; then + echo "Failed to build help tags!" + exit 1 + fi + else + echo "No docs available" + fi + + if [ -n "$addonInfo" ]; then + echo "$addonInfo" > $target/addon-info.json + fi + + echo "Finished executing vimPluginInstallPhase" +} + +preFixupHooks+=(vimPluginGenTags) + diff --git a/pkgs/misc/vim-plugins/vim-utils.nix b/pkgs/misc/vim-plugins/vim-utils.nix index 2f81820fe77e..a0293b8f5cf7 100644 --- a/pkgs/misc/vim-plugins/vim-utils.nix +++ b/pkgs/misc/vim-plugins/vim-utils.nix @@ -4,6 +4,7 @@ , fetchFromGitHub, runtimeShell , hasLuaModule , python3 +, callPackage, makeSetupHook }: /* @@ -485,7 +486,18 @@ rec { ''; }; - inherit (import ./build-vim-plugin.nix { inherit lib stdenv rtpPath vim; }) buildVimPlugin buildVimPluginFrom2Nix; + vimGenDocHook = callPackage ({ vim }: + makeSetupHook { + name = "vim-gen-doc-hook"; + deps = [ vim ]; + substitutions = { + vimBinary = "${vim}/bin/vim"; + inherit rtpPath; + }; + } ./vim-gen-doc-hook.sh) {}; + + inherit (import ./build-vim-plugin.nix { inherit lib stdenv rtpPath vim vimGenDocHook; }) + buildVimPlugin buildVimPluginFrom2Nix; # used to figure out which python dependencies etc. neovim needs requiredPlugins = {