From dddaa94ac26ecb223ca6d0a6a2121c7818d4b840 Mon Sep 17 00:00:00 2001 From: Symphorien Gibol Date: Thu, 12 Jul 2018 22:47:02 +0200 Subject: [PATCH] neovim wrapper: also make .pythonDepedencies a function A function of the same signature as the argument of python.withPackages --- pkgs/applications/editors/neovim/wrapper.nix | 22 ++++++++++--------- pkgs/misc/vim-plugins/default.nix | 2 +- pkgs/misc/vim-plugins/vim-utils.nix | 8 ++++++- .../vim2nix/additional-nix-code/ensime-vim | 2 +- 4 files changed, 21 insertions(+), 13 deletions(-) diff --git a/pkgs/applications/editors/neovim/wrapper.nix b/pkgs/applications/editors/neovim/wrapper.nix index 90b7f1ae7bea..17cf49521f1d 100644 --- a/pkgs/applications/editors/neovim/wrapper.nix +++ b/pkgs/applications/editors/neovim/wrapper.nix @@ -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}" '' ; diff --git a/pkgs/misc/vim-plugins/default.nix b/pkgs/misc/vim-plugins/default.nix index b52e63241990..4f9bae97ea7b 100644 --- a/pkgs/misc/vim-plugins/default.nix +++ b/pkgs/misc/vim-plugins/default.nix @@ -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 diff --git a/pkgs/misc/vim-plugins/vim-utils.nix b/pkgs/misc/vim-plugins/vim-utils.nix index 514c1daed629..bae1645563f0 100644 --- a/pkgs/misc/vim-plugins/vim-utils.nix +++ b/pkgs/misc/vim-plugins/vim-utils.nix @@ -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 { diff --git a/pkgs/misc/vim-plugins/vim2nix/additional-nix-code/ensime-vim b/pkgs/misc/vim-plugins/vim2nix/additional-nix-code/ensime-vim index 7d6267e95151..e065e0db4f47 100644 --- a/pkgs/misc/vim-plugins/vim2nix/additional-nix-code/ensime-vim +++ b/pkgs/misc/vim-plugins/vim2nix/additional-nix-code/ensime-vim @@ -1 +1 @@ - pythonDependencies = with pythonPackages; [ sexpdata websocket_client ]; + passthru.python3Dependencies = ps: with ps; [ sexpdata websocket_client ];