diff options
Diffstat (limited to 'pkgs/misc/vim-plugins/build-vim-plugin.nix')
-rw-r--r-- | pkgs/misc/vim-plugins/build-vim-plugin.nix | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/pkgs/misc/vim-plugins/build-vim-plugin.nix b/pkgs/misc/vim-plugins/build-vim-plugin.nix new file mode 100644 index 000000000000..fe60ad21c752 --- /dev/null +++ b/pkgs/misc/vim-plugins/build-vim-plugin.nix @@ -0,0 +1,60 @@ +{ stdenv +, rtpPath ? "share/vim-plugins" +, vim +}: + +rec { + addRtp = path: attrs: derivation: + derivation // { rtp = "${derivation}/${path}"; } // { + overrideAttrs = f: buildVimPlugin (attrs // f attrs); + }; + + buildVimPlugin = attrs@{ + name ? "${attrs.pname}-${attrs.version}", + namePrefix ? "vimplugin-", + src, + unpackPhase ? "", + configurePhase ? "", + buildPhase ? "", + preInstall ? "", + postInstall ? "", + path ? (builtins.parseDrvName name).name, + addonInfo ? null, + ... + }: + addRtp "${rtpPath}/${path}" attrs (stdenv.mkDerivation (attrs // { + name = namePrefix + name; + + inherit unpackPhase configurePhase buildPhase addonInfo preInstall postInstall; + + installPhase = '' + runHook preInstall + + target=$out/${rtpPath}/${path} + 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 -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 + ''; + })); + + buildVimPluginFrom2Nix = attrs: buildVimPlugin ({ + buildPhase = ":"; + configurePhase =":"; + } // attrs); +} |