about summary refs log tree commit diff
path: root/pkgs/applications/editors/neovim/build-neovim-plugin.nix
blob: cb69b5ecacdba16b2f84371c345ecd1e1f31d94d (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
{ lib
, stdenv
, buildVimPluginFrom2Nix
, buildLuarocksPackage
, lua51Packages
, toVimPlugin
}:
let
  # sanitizeDerivationName
  normalizeName = lib.replaceStrings [ "." ] [ "-" ];
in

  # function to create vim plugin from lua packages that are already packaged in
  # luaPackages
  {
    # the lua attribute name that matches this vim plugin. Both should be equal
    # in the majority of cases but we make it possible to have different attribute names
    luaAttr ? (normalizeName attrs.pname)
    , ...
  }@attrs:
    let
      originalLuaDrv = lua51Packages.${luaAttr};
      luaDrv = lua51Packages.lib.overrideLuarocks originalLuaDrv (drv: {
        extraConfig = ''
          -- to create a flat hierarchy
          lua_modules_path = "lua"
        '';
      });
      finalDrv = toVimPlugin (luaDrv.overrideAttrs(oa: {
          nativeBuildInputs = oa.nativeBuildInputs or [] ++ [
            lua51Packages.luarocksMoveDataFolder
          ];
        }));
    in
      finalDrv