nixpkgs/pkgs/applications/editors/vim/plugins/build-vim-plugin.nix
2022-12-23 12:37:26 -05:00

57 lines
1.2 KiB
Nix

{ lib
, stdenv
, rtpPath
, toVimPlugin
}:
rec {
addRtp = drv:
drv // {
rtp = lib.warn "`rtp` attribute is deprecated, use `outPath` instead." drv.outPath;
overrideAttrs = f: addRtp (drv.overrideAttrs f);
};
buildVimPlugin =
{ name ? "${attrs.pname}-${attrs.version}"
, namePrefix ? "vimplugin-"
, src
, unpackPhase ? ""
, configurePhase ? ""
, buildPhase ? ""
, preInstall ? ""
, postInstall ? ""
, path ? "."
, addonInfo ? null
, meta ? { }
, ...
}@attrs:
let
drv = 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
runHook postInstall
'';
meta = {
platforms = lib.platforms.all;
} // meta;
});
in
addRtp (toVimPlugin drv);
buildVimPluginFrom2Nix = attrs: buildVimPlugin ({
# vim plugins may override this
buildPhase = ":";
configurePhase = ":";
} // attrs);
}