vimUtils: apply pluginToDrv recursively

This is necessary to handle plugin dependencies which also may be
strings.
This commit is contained in:
Timo Kaufmann
2019-01-02 22:12:27 +01:00
parent 3820041ffd
commit f38363387e
+16 -17
View File
@@ -152,15 +152,21 @@ vim_with_plugins can be installed like any other application within Nix.
let let
inherit (stdenv) lib; inherit (stdenv) lib;
# make sure a plugin is a derivation. If plugin already is a derivation, this # make sure a plugin is a derivation and its dependencies are derivations. If
# is a no-op. If it is a string, it is looked up in knownPlugins. # plugin already is a derivation, this is a no-op. If it is a string, it is
# looked up in knownPlugins.
pluginToDrv = knownPlugins: plugin: pluginToDrv = knownPlugins: plugin:
if builtins.isString plugin then let
# make sure `pname` is set to that we are able to convert the derivation drv =
# back to a string. if builtins.isString plugin then
( knownPlugins.${plugin} // { pname = plugin; }) # make sure `pname` is set to that we are able to convert the derivation
else # back to a string.
plugin; ( knownPlugins.${plugin} // { pname = plugin; })
else
plugin;
in
# make sure all the dependencies of the plugin are also derivations
drv // { dependencies = map (pluginToDrv knownPlugins) (drv.dependencies or []); };
# transitive closure of plugin dependencies (plugin needs to be a derivation) # transitive closure of plugin dependencies (plugin needs to be a derivation)
transitiveClosure = plugin: transitiveClosure = plugin:
@@ -170,14 +176,6 @@ let
findDependenciesRecursively = plugins: lib.concatMap transitiveClosure plugins; findDependenciesRecursively = plugins: lib.concatMap transitiveClosure plugins;
attrnamesToPlugins = { knownPlugins, names }:
map (name: if builtins.isString name then knownPlugins.${name} else name) knownPlugins;
pluginToAttrname = plugin:
plugin.pname;
pluginsToAttrnames = plugins: map pluginToAttrname plugins;
vamDictToNames = x: vamDictToNames = x:
if builtins.isString x then [x] if builtins.isString x then [x]
else (lib.optional (x ? name) x.name) else (lib.optional (x ? name) x.name)
@@ -482,7 +480,8 @@ rec {
rev = "4c596548216b7c19971f8fc94e38ef1a2b55fee6"; rev = "4c596548216b7c19971f8fc94e38ef1a2b55fee6";
sha256 = "0f1cpnp1nxb4i5hgymjn2yn3k1jwkqmlgw1g02sq270lavp2dzs9"; sha256 = "0f1cpnp1nxb4i5hgymjn2yn3k1jwkqmlgw1g02sq270lavp2dzs9";
}; };
dependencies = []; # make sure string dependencies are handled
dependencies = [ "vim-nix" ];
}; };
}); });
vimrcConfig.vam.pluginDictionaries = [ { names = [ "vim-trailing-whitespace" ]; } ]; vimrcConfig.vam.pluginDictionaries = [ { names = [ "vim-trailing-whitespace" ]; } ];