-
-
Notifications
You must be signed in to change notification settings - Fork 15k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
vimPlugins: use lua derivation if it exists (#178180)
Neovim plugins are now more often than not written in lua. One advantage of the lua ecosystem over vim's is the existence of luarocks and the rockspec format, which allows to specify a package dependencies formally. I would like more neovim plugins to have a formal description, "rockspec" being the current candidate. This MR allows to use nix lua packages as neovim plugins, so as to enjoy every benefit that rockspecs bring: - dependdency discovery - ability to run test suite - luarocks versioning - rockspec metadata the vim update.py script will check if an attribute with the vim plugin pname exists in lua51Packages. If it does, it uses buildNeovimPluginFrom2Nix on it, which modifies the luarocks config to do an almost flat install (luarocks will install the package in the lua folder instead of share/5.1/lua etc). It also calls toVimPlugin on it to get all the vim plugin niceties. The list of packages that could benefit from this is available at https://luarocks.org/labels/neovim but I hope it grows.
- Loading branch information
Showing
10 changed files
with
105 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
pkgs/development/interpreters/lua-5/hooks/luarocks-move-data.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# luarocks installs data in a non-overridable location. Until a proper luarocks patch, | ||
# we move the files around ourselves | ||
echo "Sourcing luarocks-move-data-hook.sh" | ||
|
||
luarocksMoveDataHook () { | ||
echo "Executing luarocksMoveDataHook" | ||
if [ -d "$out/$rocksSubdir" ]; then | ||
cp -rfv "$out/$rocksSubdir/$pname/$version/." "$out" | ||
fi | ||
|
||
echo "Finished executing luarocksMoveDataHook" | ||
} | ||
|
||
echo "Using luarocksMoveDataHook" | ||
preDistPhases+=" luarocksMoveDataHook" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters