vimPlugins: split doc generation into a hook
so that the hook can be used for lua modules as well. Improves composition.
This commit is contained in:
parent
9dea98679d
commit
1fa84e3e02
6 changed files with 65 additions and 19 deletions
|
@ -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
|
||||
'';
|
||||
}));
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
|
13
pkgs/misc/vim-plugins/update-shell.nix
Normal file
13
pkgs/misc/vim-plugins/update-shell.nix
Normal file
|
@ -0,0 +1,13 @@
|
|||
{ nixpkgs ? import ../../.. { } }:
|
||||
with nixpkgs;
|
||||
let
|
||||
pyEnv = python3.withPackages(ps: [ ps.GitPython ]);
|
||||
in
|
||||
mkShell {
|
||||
packages = [
|
||||
bash
|
||||
pyEnv
|
||||
nix-prefetch-scripts
|
||||
];
|
||||
}
|
||||
|
|
@ -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
|
||||
|
|
31
pkgs/misc/vim-plugins/vim-gen-doc-hook.sh
Normal file
31
pkgs/misc/vim-plugins/vim-gen-doc-hook.sh
Normal file
|
@ -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)
|
||||
|
|
@ -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 = {
|
||||
|
|
Loading…
Reference in a new issue