diff options
author | Matthieu Coudron <mcoudron@hotmail.com> | 2021-09-03 16:50:36 +0200 |
---|---|---|
committer | Matthieu Coudron <teto@users.noreply.github.com> | 2021-09-04 00:12:35 +0200 |
commit | 1fa84e3e027e8a830f129b58439db7c037530d75 (patch) | |
tree | b28eefb7209ed7f75a6103270afe4041c5d053f7 /pkgs/misc | |
parent | 9dea98679d45d22c85ff2fc5d190ebbe5b03d6bc (diff) | |
download | nixlib-1fa84e3e027e8a830f129b58439db7c037530d75.tar nixlib-1fa84e3e027e8a830f129b58439db7c037530d75.tar.gz nixlib-1fa84e3e027e8a830f129b58439db7c037530d75.tar.bz2 nixlib-1fa84e3e027e8a830f129b58439db7c037530d75.tar.lz nixlib-1fa84e3e027e8a830f129b58439db7c037530d75.tar.xz nixlib-1fa84e3e027e8a830f129b58439db7c037530d75.tar.zst nixlib-1fa84e3e027e8a830f129b58439db7c037530d75.zip |
vimPlugins: split doc generation into a hook
so that the hook can be used for lua modules as well. Improves composition.
Diffstat (limited to 'pkgs/misc')
-rw-r--r-- | pkgs/misc/vim-plugins/build-vim-plugin.nix | 19 | ||||
-rw-r--r-- | pkgs/misc/vim-plugins/default.nix | 4 | ||||
-rw-r--r-- | pkgs/misc/vim-plugins/update-shell.nix | 13 | ||||
-rwxr-xr-x | pkgs/misc/vim-plugins/update.py | 3 | ||||
-rw-r--r-- | pkgs/misc/vim-plugins/vim-gen-doc-hook.sh | 31 | ||||
-rw-r--r-- | pkgs/misc/vim-plugins/vim-utils.nix | 14 |
6 files changed, 65 insertions, 19 deletions
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 = { |