Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)

vimPlugins: split doc generation into a hook

so that the hook can be used for lua modules as well. Improves
composition.

authored by

Matthieu Coudron and committed by
Matthieu Coudron
1fa84e3e 9dea9867

+65 -19
+3 -16
pkgs/misc/vim-plugins/build-vim-plugin.nix
··· 1 1 { lib, stdenv 2 - , rtpPath ? "share/vim-plugins" 2 + , rtpPath 3 3 , vim 4 + , vimGenDocHook 4 5 }: 5 6 6 7 rec { ··· 25 26 addRtp "${rtpPath}/${path}" attrs (stdenv.mkDerivation (attrs // { 26 27 name = namePrefix + name; 27 28 29 + nativeBuildInputs = attrs.nativeBuildInputs or [] ++ [ vimGenDocHook ]; 28 30 inherit unpackPhase configurePhase buildPhase addonInfo preInstall postInstall; 29 31 30 32 installPhase = '' ··· 33 35 target=$out/${rtpPath}/${path} 34 36 mkdir -p $out/${rtpPath} 35 37 cp -r . $target 36 - 37 - # build help tags 38 - if [ -d "$target/doc" ]; then 39 - echo "Building help tags" 40 - if ! ${vim}/bin/vim -N -u NONE -i NONE -n -E -s -V1 -c "helptags $target/doc" +quit!; then 41 - echo "Failed to build help tags!" 42 - exit 1 43 - fi 44 - else 45 - echo "No docs available" 46 - fi 47 - 48 - if [ -n "$addonInfo" ]; then 49 - echo "$addonInfo" > $target/addon-info.json 50 - fi 51 38 52 39 runHook postInstall 53 40 '';
+3 -1
pkgs/misc/vim-plugins/default.nix
··· 3 3 4 4 let 5 5 6 - inherit (vimUtils.override {inherit vim;}) buildVimPluginFrom2Nix; 6 + inherit (vimUtils.override {inherit vim;}) buildVimPluginFrom2Nix vimGenDocHook; 7 7 8 8 inherit (lib) extends; 9 9 ··· 11 11 # Convert derivation to a vim plugin. 12 12 toVimPlugin = drv: 13 13 drv.overrideAttrs(oldAttrs: { 14 + 15 + nativeBuildInputs = oldAttrs.nativeBuildInputs or [] ++ [ vimGenDocHook ]; 14 16 passthru = (oldAttrs.passthru or {}) // { 15 17 vimPlugin = true; 16 18 };
+13
pkgs/misc/vim-plugins/update-shell.nix
··· 1 + { nixpkgs ? import ../../.. { } }: 2 + with nixpkgs; 3 + let 4 + pyEnv = python3.withPackages(ps: [ ps.GitPython ]); 5 + in 6 + mkShell { 7 + packages = [ 8 + bash 9 + pyEnv 10 + nix-prefetch-scripts 11 + ]; 12 + } 13 +
+2 -1
pkgs/misc/vim-plugins/update.py
··· 1 1 #!/usr/bin/env nix-shell 2 - #!nix-shell -p nix-prefetch-git -p python3 -p python3Packages.GitPython nix -i python3 2 + #!nix-shell update-shell.nix -i python3 3 + 3 4 4 5 # format: 5 6 # $ nix run nixpkgs.python3Packages.black -c black update.py
+31
pkgs/misc/vim-plugins/vim-gen-doc-hook.sh
··· 1 + echo "Sourcing vim-gen-doc-hook" 2 + 3 + # the doc folder is copied via the copy_directories entry of the rockspec 4 + # in the folder gitsigns.nvim-scm-1-rocks/gitsigns.nvim/scm-1 5 + vimPluginGenTags() { 6 + echo "Executing vimPluginGenTags" 7 + 8 + target="$out/@rtpPath@/$pname" 9 + mkdir -p $out/@rtpPath@ 10 + cp -r . $target 11 + 12 + # build help tags 13 + if [ -d "$target/doc" ]; then 14 + echo "Building help tags" 15 + if ! @vimBinary@ -N -u NONE -i NONE -n -E -s -V1 -c "helptags $target/doc" +quit!; then 16 + echo "Failed to build help tags!" 17 + exit 1 18 + fi 19 + else 20 + echo "No docs available" 21 + fi 22 + 23 + if [ -n "$addonInfo" ]; then 24 + echo "$addonInfo" > $target/addon-info.json 25 + fi 26 + 27 + echo "Finished executing vimPluginInstallPhase" 28 + } 29 + 30 + preFixupHooks+=(vimPluginGenTags) 31 +
+13 -1
pkgs/misc/vim-plugins/vim-utils.nix
··· 4 4 , fetchFromGitHub, runtimeShell 5 5 , hasLuaModule 6 6 , python3 7 + , callPackage, makeSetupHook 7 8 }: 8 9 9 10 /* ··· 485 486 ''; 486 487 }; 487 488 488 - inherit (import ./build-vim-plugin.nix { inherit lib stdenv rtpPath vim; }) buildVimPlugin buildVimPluginFrom2Nix; 489 + vimGenDocHook = callPackage ({ vim }: 490 + makeSetupHook { 491 + name = "vim-gen-doc-hook"; 492 + deps = [ vim ]; 493 + substitutions = { 494 + vimBinary = "${vim}/bin/vim"; 495 + inherit rtpPath; 496 + }; 497 + } ./vim-gen-doc-hook.sh) {}; 498 + 499 + inherit (import ./build-vim-plugin.nix { inherit lib stdenv rtpPath vim vimGenDocHook; }) 500 + buildVimPlugin buildVimPluginFrom2Nix; 489 501 490 502 # used to figure out which python dependencies etc. neovim needs 491 503 requiredPlugins = {