about summary refs log tree commit diff
path: root/nixpkgs/pkgs/applications/editors/vim/plugins/build-vim-plugin.nix
blob: 1611adc97ee3bfe0d6b474c92bac4172fa8d905a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
{ 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);

}