1{ lib, stdenv
2, rtpPath
3, vim
4, vimGenDocHook
5}:
6
7rec {
8 addRtp = path: attrs: derivation:
9 derivation // { rtp = "${derivation}"; } // {
10 overrideAttrs = f: buildVimPlugin (attrs // f attrs);
11 };
12
13 buildVimPlugin = attrs@{
14 name ? "${attrs.pname}-${attrs.version}",
15 namePrefix ? "vimplugin-",
16 src,
17 unpackPhase ? "",
18 configurePhase ? "",
19 buildPhase ? "",
20 preInstall ? "",
21 postInstall ? "",
22 path ? ".",
23 addonInfo ? null,
24 ...
25 }:
26 addRtp "${rtpPath}/${path}" attrs (stdenv.mkDerivation (attrs // {
27 name = namePrefix + name;
28
29 # dont move the doc folder since vim expects it
30 forceShare= [ "man" "info" ];
31
32 nativeBuildInputs = attrs.nativeBuildInputs or []
33 ++ lib.optional (stdenv.hostPlatform == stdenv.buildPlatform) vimGenDocHook;
34 inherit unpackPhase configurePhase buildPhase addonInfo preInstall postInstall;
35
36 installPhase = ''
37 runHook preInstall
38
39 target=$out/${rtpPath}/${path}
40 mkdir -p $out/${rtpPath}
41 cp -r . $target
42
43 runHook postInstall
44 '';
45 }));
46
47 buildVimPluginFrom2Nix = attrs: buildVimPlugin ({
48 # vim plugins may override this
49 buildPhase = ":";
50 configurePhase =":";
51 } // attrs);
52}