right now the src is ignored in: ``` lush-nvim = buildNeovimPlugin { pname = "lush.nvim"; version = "2022-08-09"; src = fetchFromGitHub { owner = "rktjmp"; repo = "lush.nvim"; rev = "6b9f399245de7bea8dac2c3bf91096ffdedfcbb7"; sha256 = "0rb77rwmbm438bmbjfk5hwrrcn5sihsa1413bdpc27rw3rrn8v8z"; }; meta.homepage = "https://github.com/rktjmp/lush.nvim/"; }; ``` which is very confusing. With this PR, we correctly override the src and the version of the package. We introduce a rockspecVersion attribute of lua package to be able to still find the rockspec when the "version" field needs to be different than "rockspecVersion".
39 lines
1 KiB
Nix
39 lines
1 KiB
Nix
{ 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 = (lua.pkgs.luaLib.overrideLuarocks originalLuaDrv (drv: {
|
|
extraConfig = ''
|
|
-- to create a flat hierarchy
|
|
lua_modules_path = "lua"
|
|
'';
|
|
})).overrideAttrs (drv: {
|
|
version = attrs.version;
|
|
rockspecVersion = drv.rockspecVersion;
|
|
});
|
|
|
|
finalDrv = toVimPlugin (luaDrv.overrideAttrs(oa: attrs // {
|
|
nativeBuildInputs = oa.nativeBuildInputs or [] ++ [
|
|
lua.pkgs.luarocksMoveDataFolder
|
|
];
|
|
}));
|
|
in
|
|
finalDrv
|