summary refs log tree commit diff
diff options
context:
space:
mode:
authorJörg Thalheim <Mic92@users.noreply.github.com>2018-08-30 08:51:21 +0100
committerGitHub <noreply@github.com>2018-08-30 08:51:21 +0100
commit663951eaa30412ea15a3ff56364b64fe434746c3 (patch)
tree6e1834daffd748603cf964271a9e5fdd08e03188
parentb470ed6b78fe1b252eb5c03e8340e4f940c4cd59 (diff)
parentdddaa94ac26ecb223ca6d0a6a2121c7818d4b840 (diff)
downloadnixpkgs-663951eaa30412ea15a3ff56364b64fe434746c3.tar
nixpkgs-663951eaa30412ea15a3ff56364b64fe434746c3.tar.gz
nixpkgs-663951eaa30412ea15a3ff56364b64fe434746c3.tar.bz2
nixpkgs-663951eaa30412ea15a3ff56364b64fe434746c3.tar.lz
nixpkgs-663951eaa30412ea15a3ff56364b64fe434746c3.tar.xz
nixpkgs-663951eaa30412ea15a3ff56364b64fe434746c3.tar.zst
nixpkgs-663951eaa30412ea15a3ff56364b64fe434746c3.zip
Merge pull request #43388 from symphorien/neovim-python-env
Fix neovim PYTHONPATH handling
-rw-r--r--pkgs/applications/editors/neovim/wrapper.nix51
-rw-r--r--pkgs/misc/vim-plugins/default.nix2
-rw-r--r--pkgs/misc/vim-plugins/vim-utils.nix8
-rw-r--r--pkgs/misc/vim-plugins/vim2nix/additional-nix-code/ensime-vim2
4 files changed, 35 insertions, 28 deletions
diff --git a/pkgs/applications/editors/neovim/wrapper.nix b/pkgs/applications/editors/neovim/wrapper.nix
index fa060325559..17cf49521f1 100644
--- a/pkgs/applications/editors/neovim/wrapper.nix
+++ b/pkgs/applications/editors/neovim/wrapper.nix
@@ -10,13 +10,13 @@ neovim:
 
 let
   wrapper = {
-      withPython ? true,  extraPythonPackages ? []
-    , withPython3 ? true,  extraPython3Packages ? []
+      withPython ? true,  extraPythonPackages ? (_: []) /* the function you would have passed to python.withPackages */
+    , withPython3 ? true,  extraPython3Packages ? (_: []) /* the function you would have passed to python.withPackages */
     , withRuby ? true
     , withPyGUI ? false
     , vimAlias ? false
     , viAlias ? false
-    , configure ? null
+    , configure ? {}
   }:
   let
 
@@ -28,25 +28,27 @@ let
     '';
   };
 
-  pluginPythonPackages = if configure == null then [] else builtins.concatLists
-    (map ({ pythonDependencies ? [], ...}: pythonDependencies)
-         (vimUtils.requiredPlugins configure));
-  pythonEnv = pythonPackages.python.buildEnv.override {
-    extraLibs = (
-        if withPyGUI
-          then [ pythonPackages.neovim_gui ]
-          else [ pythonPackages.neovim ]
-      ) ++ extraPythonPackages ++ pluginPythonPackages;
-    ignoreCollisions = true;
-  };
+  /* for compatibility with passing extraPythonPackages as a list; added 2018-07-11 */
+  compatFun = funOrList: (if builtins.isList funOrList then
+    (_: builtins.trace "passing a list as extraPythonPackages to the neovim wrapper is deprecated, pass a function as to python.withPackages instead" funOrList)
+    else funOrList);
+  extraPythonPackagesFun = compatFun extraPythonPackages;
+  extraPython3PackagesFun = compatFun extraPython3Packages;
 
-  pluginPython3Packages = if configure == null then [] else builtins.concatLists
-    (map ({ python3Dependencies ? [], ...}: python3Dependencies)
-         (vimUtils.requiredPlugins configure));
-  python3Env = python3Packages.python.buildEnv.override {
-    extraLibs = [ python3Packages.neovim ] ++ extraPython3Packages ++ pluginPython3Packages;
-    ignoreCollisions = true;
-  };
+  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)
+        ++ (concatMap (f: f ps) pluginPythonPackages));
+
+  pluginPython3Packages = getDeps "python3Dependencies" requiredPlugins;
+  python3Env = python3Packages.python.withPackages (ps:
+        [ ps.neovim ]
+        ++ (extraPython3PackagesFun ps)
+        ++ (concatMap (f: f ps) pluginPython3Packages));
 
   in
   stdenv.mkDerivation {
@@ -63,7 +65,6 @@ let
         --cmd \"${if withPython then "let g:python_host_prog='$out/bin/nvim-python'" else "let g:loaded_python_provider = 1"}\" \
         --cmd \"${if withPython3 then "let g:python3_host_prog='$out/bin/nvim-python3'" else "let g:loaded_python3_provider = 1"}\" \
         --cmd \"${if withRuby then "let g:ruby_host_prog='$out/bin/nvim-ruby'" else "let g:loaded_ruby_provider=1"}\" " \
-        --unset PYTHONPATH \
          ${optionalString withRuby '' --suffix PATH : ${rubyEnv}/bin --set GEM_HOME ${rubyEnv}/${rubyEnv.ruby.gemPath}'' }
 
       ''
@@ -75,9 +76,9 @@ let
           --replace 'Name=Neovim' 'Name=WrappedNeovim'
       ''
       + optionalString withPython ''
-      ln -s ${pythonEnv}/bin/python $out/bin/nvim-python
+        makeWrapper ${pythonEnv}/bin/python $out/bin/nvim-python --unset PYTHONPATH
     '' + optionalString withPython3 ''
-      ln -s ${python3Env}/bin/python3 $out/bin/nvim-python3
+        makeWrapper ${python3Env}/bin/python3 $out/bin/nvim-python3 --unset PYTHONPATH
     '' + optionalString withRuby ''
       ln -s ${rubyEnv}/bin/neovim-ruby-host $out/bin/nvim-ruby
     ''
@@ -88,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 f32c1795409..d251b2da45c 100644
--- a/pkgs/misc/vim-plugins/default.nix
+++ b/pkgs/misc/vim-plugins/default.nix
@@ -1004,7 +1004,7 @@ self = rec {
       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 514c1daed62..bae1645563f 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 7d6267e9515..e065e0db4f4 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 ];