neovim wrapper: also make <vimplugin>.pythonDepedencies a function

A function of the same signature as the argument of python.withPackages
This commit is contained in:
Symphorien Gibol 2018-07-12 22:47:02 +02:00
parent c1752666df
commit dddaa94ac2
4 changed files with 21 additions and 13 deletions

View File

@ -16,7 +16,7 @@ let
, withPyGUI ? false
, vimAlias ? false
, viAlias ? false
, configure ? null
, configure ? {}
}:
let
@ -35,18 +35,20 @@ let
extraPythonPackagesFun = compatFun extraPythonPackages;
extraPython3PackagesFun = compatFun extraPython3Packages;
pluginPythonPackages = if configure == null then [] else builtins.concatLists
(map ({ pythonDependencies ? [], ...}: pythonDependencies)
(vimUtils.requiredPlugins configure));
requiredPlugins = vimUtils.requiredPlugins configure;
getDeps = attrname: map (plugin: plugin.${attrname} or (_:[]));
pluginPythonPackages = getDeps "pythonDependencies" requiredPlugins;
pythonEnv = pythonPackages.python.withPackages(ps:
(if withPyGUI then [ ps.neovim_gui ] else [ ps.neovim ])
++ (extraPythonPackagesFun ps) ++ pluginPythonPackages);
++ (extraPythonPackagesFun ps)
++ (concatMap (f: f ps) pluginPythonPackages));
pluginPython3Packages = if configure == null then [] else builtins.concatLists
(map ({ python3Dependencies ? [], ...}: python3Dependencies)
(vimUtils.requiredPlugins configure));
pluginPython3Packages = getDeps "python3Dependencies" requiredPlugins;
python3Env = python3Packages.python.withPackages (ps:
[ ps.neovim ] ++ (extraPython3PackagesFun ps) ++ pluginPython3Packages);
[ ps.neovim ]
++ (extraPython3PackagesFun ps)
++ (concatMap (f: f ps) pluginPython3Packages));
in
stdenv.mkDerivation {
@ -87,7 +89,7 @@ let
ln -s $out/bin/nvim $out/bin/vim
'' + optionalString viAlias ''
ln -s $out/bin/nvim $out/bin/vi
'' + optionalString (configure != null) ''
'' + optionalString (configure != {}) ''
wrapProgram $out/bin/nvim --add-flags "-u ${vimUtils.vimrcFile configure}"
''
;

View File

@ -1015,7 +1015,7 @@ let
sha256 = "03sr53680kcwxaa5xbqzdfbsgday3bkzja33wym49w9gjmlaa320";
};
dependencies = ["vimproc" "vimshell" "self" "forms"];
pythonDependencies = with pythonPackages; [ sexpdata websocket_client ];
passthru.python3Dependencies = ps: with ps; [ sexpdata websocket_client ];
};
supertab = buildVimPluginFrom2Nix { # created by nix#NixDerivation

View File

@ -280,6 +280,7 @@ let
installPhase = lib.concatStringsSep
"\n"
(lib.flatten (lib.mapAttrsToList packageLinks packages));
preferLocalBuild = true;
}
);
in
@ -423,6 +424,7 @@ rec {
} // a);
requiredPlugins = {
packages ? {},
givenKnownPlugins ? null,
vam ? null,
pathogen ? null, ...
@ -437,8 +439,12 @@ rec {
vamNames = findDependenciesRecursively { inherit knownPlugins; names = lib.concatMap toNames vam.pluginDictionaries; };
names = (lib.optionals (pathogen != null) pathogenNames) ++
(lib.optionals (vam != null) vamNames);
nonNativePlugins = map (name: knownPlugins.${name}) names;
nativePluginsConfigs = lib.attrsets.attrValues packages;
nativePlugins = lib.concatMap ({start?[], opt?[]}: start++opt) nativePluginsConfigs;
in
map (name: knownPlugins.${name}) names;
nativePlugins ++ nonNativePlugins;
# test cases:
test_vim_with_vim_addon_nix_using_vam = vim_configurable.customize {

View File

@ -1 +1 @@
pythonDependencies = with pythonPackages; [ sexpdata websocket_client ];
passthru.python3Dependencies = ps: with ps; [ sexpdata websocket_client ];