3
0
Fork 0
forked from mirrors/nixpkgs
nixpkgs/pkgs/applications/editors/vim/plugins/build-vim-plugin.nix
Matthieu Coudron 9663a29afa buildVimPlugin: add vimCommandCheckHook
Modeled after pythonImportCheckHook, this checks a command can be run once the plugin is installed
2022-04-30 23:54:25 +02:00

55 lines
1.3 KiB
Nix

{ lib, stdenv
, rtpPath
, vim
, vimCommandCheckHook
, vimGenDocHook
}:
rec {
addRtp = path: attrs: derivation:
derivation // { rtp = "${derivation}"; } // {
overrideAttrs = f: buildVimPlugin (attrs // f attrs);
};
buildVimPlugin = attrs@{
name ? "${attrs.pname}-${attrs.version}",
namePrefix ? "vimplugin-",
src,
unpackPhase ? "",
configurePhase ? "",
buildPhase ? "",
preInstall ? "",
postInstall ? "",
path ? ".",
addonInfo ? null,
...
}:
addRtp "${rtpPath}/${path}" attrs (stdenv.mkDerivation (attrs // {
name = namePrefix + name;
# dont move the doc folder since vim expects it
forceShare= [ "man" "info" ];
nativeBuildInputs = attrs.nativeBuildInputs or []
++ [ vimCommandCheckHook ]
++ lib.optional (stdenv.hostPlatform == stdenv.buildPlatform) vimGenDocHook;
inherit unpackPhase configurePhase buildPhase addonInfo preInstall postInstall;
installPhase = ''
runHook preInstall
target=$out/${rtpPath}/${path}
mkdir -p $out/${rtpPath}
cp -r . $target
runHook postInstall
'';
}));
buildVimPluginFrom2Nix = attrs: buildVimPlugin ({
# vim plugins may override this
buildPhase = ":";
configurePhase =":";
} // attrs);
}