mirror of
https://github.com/nix-community/nixvim.git
synced 2026-08-28 02:34:17 -05:00
`combinePlugins` dropped the `runtimeDeps` of the combined plugins. The neovim wrapper then lost those PATH entries when `autowrapRuntimeDeps` was enabled. Aggregate `runtimeDeps` from the combined plugins and pass them through the plugin pack. nixpkgs reads the resulting `plugin.runtimeDeps` in `plugin-submodule.nix`.
109 lines
2.9 KiB
Nix
109 lines
2.9 KiB
Nix
{
|
|
lib,
|
|
buildEnv,
|
|
vimUtils,
|
|
}:
|
|
let
|
|
inherit (import ./utils.nix lib) normalizePlugin;
|
|
in
|
|
{ pluginsToCombine, pathsToLink }:
|
|
let
|
|
|
|
overridePlugin =
|
|
plugin:
|
|
plugin.plugin.overrideAttrs (prev: {
|
|
nativeBuildInputs = builtins.filter (
|
|
drv: lib.getName drv != "vim-gen-doc-hook"
|
|
) prev.nativeBuildInputs or [ ];
|
|
configurePhase = ''
|
|
${prev.configurePhase or ""}
|
|
rm -vf doc/tags'';
|
|
});
|
|
|
|
# Every plugin has its own generated help tags (doc/tags)
|
|
# Remove them to avoid collisions, new help tags
|
|
# will be generate for the entire pack later on
|
|
overriddenPlugins = map overridePlugin pluginsToCombine;
|
|
|
|
# Gather python 3 dependencies from every plugins
|
|
python3Dependencies =
|
|
ps:
|
|
lib.pipe pluginsToCombine [
|
|
(builtins.catAttrs "plugin")
|
|
(builtins.catAttrs "python3Dependencies")
|
|
(builtins.concatMap (f: f ps))
|
|
];
|
|
|
|
# nixpkgs reads `plugin.runtimeDeps` in plugin-submodule.nix to suffix PATH
|
|
# in the neovim wrapper when `autowrapRuntimeDeps` is enabled.
|
|
runtimeDeps = lib.pipe pluginsToCombine [
|
|
(builtins.catAttrs "plugin")
|
|
(builtins.catAttrs "runtimeDeps")
|
|
builtins.concatLists
|
|
lib.unique
|
|
];
|
|
|
|
requiredLuaModules = lib.pipe pluginsToCombine [
|
|
(builtins.catAttrs "plugin")
|
|
(builtins.catAttrs "requiredLuaModules")
|
|
builtins.concatLists
|
|
lib.unique
|
|
];
|
|
|
|
# propagatedBuildInputs contain lua dependencies
|
|
propagatedBuildInputs = lib.pipe pluginsToCombine [
|
|
(builtins.catAttrs "plugin")
|
|
(builtins.catAttrs "propagatedBuildInputs")
|
|
builtins.concatLists
|
|
lib.unique
|
|
];
|
|
|
|
# Combined plugin
|
|
combinedPlugin =
|
|
lib.pipe
|
|
{
|
|
name = "plugin-pack";
|
|
paths = overriddenPlugins;
|
|
inherit pathsToLink;
|
|
|
|
# buildEnv uses runCommand under the hood. runCommand doesn't run any build phases.
|
|
# To run custom commands buildEnv takes postBuild argument.
|
|
# fixupPhase is used for propagating build inputs and to trigger vimGenDocHook
|
|
postBuild = ''
|
|
find $out -type d -empty -delete
|
|
fixupPhase
|
|
'';
|
|
passthru = {
|
|
# The wrapper reads these, not the pack build. `python3Dependencies`
|
|
# is a function, which a derivation attribute cannot hold.
|
|
# `runtimeDeps` as one would pull every dependency into the pack's
|
|
# build closure.
|
|
inherit python3Dependencies runtimeDeps;
|
|
};
|
|
}
|
|
[
|
|
buildEnv
|
|
vimUtils.toVimPlugin
|
|
(
|
|
drv:
|
|
drv.overrideAttrs {
|
|
inherit
|
|
propagatedBuildInputs
|
|
requiredLuaModules
|
|
;
|
|
}
|
|
)
|
|
];
|
|
|
|
# Combined plugin configs
|
|
combinedConfig = lib.pipe pluginsToCombine [
|
|
(builtins.catAttrs "config")
|
|
(builtins.filter (config: config != null && config != ""))
|
|
(builtins.concatStringsSep "\n")
|
|
];
|
|
in
|
|
normalizePlugin {
|
|
plugin = combinedPlugin;
|
|
config = combinedConfig;
|
|
}
|