about summary refs log tree commit diff
path: root/pkgs/applications/editors/neovim/build-neovim-plugin.nix
blob: 9d9778c1fe3b5ab7747f38c40fc5138910e7304a (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
{ lib
, stdenv
, lua
, 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 = lua.pkgs.${luaAttr};

      luaDrv = originalLuaDrv.overrideAttrs (oa: {
        version = attrs.version or oa.version;
        rockspecVersion = oa.rockspecVersion;

        extraConfig = ''
          -- to create a flat hierarchy
          lua_modules_path = "lua"
        '';
      });

      finalDrv = toVimPlugin (luaDrv.overrideAttrs(oa: attrs // {
          nativeBuildInputs = oa.nativeBuildInputs or [] ++ [
            lua.pkgs.luarocksMoveDataFolder
          ];
          version = "${originalLuaDrv.version}-unstable-${oa.version}";
        }));
    in
      finalDrv