wrapper/build: improve noBuildPlug

This commit is contained in:
diniamo 2025-01-01 12:59:13 +01:00
parent ecc9b60a2d
commit af0eed84e0

View file

@ -9,30 +9,35 @@
inherit (pkgs) vimPlugins; inherit (pkgs) vimPlugins;
inherit (lib.strings) isString; inherit (lib.strings) isString;
inherit (lib.lists) filter map; inherit (lib.lists) filter map;
inherit (builtins) path;
# alias to the internal configuration # alias to the internal configuration
vimOptions = config.vim; vimOptions = config.vim;
noBuildPlug = {pname, ...} @ attrs: let noBuildPlug = pname: let
src = inputs."plugin-${attrs.pname}"; input = inputs."plugin-${pname}";
in version = input.shortRev or input.shortDirtyRev or "dirty";
{ in {
version = src.shortRev or src.shortDirtyRev or "dirty"; # vim.lazy.plugins relies on pname, so we only set that here
outPath = src; # version isn't needed for anything, but inherit it anyway for correctness
passthru.vimPlugin = false; inherit pname version;
} outPath = path {
// attrs; name = "${pname}-0-unstable-${version}";
path = input.outPath;
};
passthru.vimPlugin = false;
};
# build a vim plugin with the given name and arguments # build a vim plugin with the given name and arguments
# if the plugin is nvim-treesitter, warn the user to use buildTreesitterPlug # if the plugin is nvim-treesitter, warn the user to use buildTreesitterPlug
# instead # instead
buildPlug = attrs: let buildPlug = attrs: let
src = inputs."plugin-${attrs.pname}"; input = inputs."plugin-${attrs.pname}";
in in
pkgs.vimUtils.buildVimPlugin ( pkgs.vimUtils.buildVimPlugin (
{ {
version = src.shortRev or src.shortDirtyRev or "dirty"; version = input.shortRev or input.shortDirtyRev or "dirty";
inherit src; src = input.outPath;
} }
// attrs // attrs
); );
@ -51,7 +56,7 @@
map ( map (
plug: plug:
if (isString plug) if (isString plug)
then pluginBuilders.${plug} or (noBuildPlug {pname = plug;}) then pluginBuilders.${plug} or (noBuildPlug plug)
else plug else plug
) (filter (f: f != null) plugins); ) (filter (f: f != null) plugins);