Merge pull request #43388 from symphorien/neovim-python-env
Fix neovim PYTHONPATH handling
This commit is contained in:
commit
663951eaa3
@ -10,13 +10,13 @@ neovim:
|
|||||||
|
|
||||||
let
|
let
|
||||||
wrapper = {
|
wrapper = {
|
||||||
withPython ? true, extraPythonPackages ? []
|
withPython ? true, extraPythonPackages ? (_: []) /* the function you would have passed to python.withPackages */
|
||||||
, withPython3 ? true, extraPython3Packages ? []
|
, withPython3 ? true, extraPython3Packages ? (_: []) /* the function you would have passed to python.withPackages */
|
||||||
, withRuby ? true
|
, withRuby ? true
|
||||||
, withPyGUI ? false
|
, withPyGUI ? false
|
||||||
, vimAlias ? false
|
, vimAlias ? false
|
||||||
, viAlias ? false
|
, viAlias ? false
|
||||||
, configure ? null
|
, configure ? {}
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
|
|
||||||
@ -28,25 +28,27 @@ let
|
|||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
pluginPythonPackages = if configure == null then [] else builtins.concatLists
|
/* for compatibility with passing extraPythonPackages as a list; added 2018-07-11 */
|
||||||
(map ({ pythonDependencies ? [], ...}: pythonDependencies)
|
compatFun = funOrList: (if builtins.isList funOrList then
|
||||||
(vimUtils.requiredPlugins configure));
|
(_: builtins.trace "passing a list as extraPythonPackages to the neovim wrapper is deprecated, pass a function as to python.withPackages instead" funOrList)
|
||||||
pythonEnv = pythonPackages.python.buildEnv.override {
|
else funOrList);
|
||||||
extraLibs = (
|
extraPythonPackagesFun = compatFun extraPythonPackages;
|
||||||
if withPyGUI
|
extraPython3PackagesFun = compatFun extraPython3Packages;
|
||||||
then [ pythonPackages.neovim_gui ]
|
|
||||||
else [ pythonPackages.neovim ]
|
|
||||||
) ++ extraPythonPackages ++ pluginPythonPackages;
|
|
||||||
ignoreCollisions = true;
|
|
||||||
};
|
|
||||||
|
|
||||||
pluginPython3Packages = if configure == null then [] else builtins.concatLists
|
requiredPlugins = vimUtils.requiredPlugins configure;
|
||||||
(map ({ python3Dependencies ? [], ...}: python3Dependencies)
|
getDeps = attrname: map (plugin: plugin.${attrname} or (_:[]));
|
||||||
(vimUtils.requiredPlugins configure));
|
|
||||||
python3Env = python3Packages.python.buildEnv.override {
|
pluginPythonPackages = getDeps "pythonDependencies" requiredPlugins;
|
||||||
extraLibs = [ python3Packages.neovim ] ++ extraPython3Packages ++ pluginPython3Packages;
|
pythonEnv = pythonPackages.python.withPackages(ps:
|
||||||
ignoreCollisions = true;
|
(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
|
in
|
||||||
stdenv.mkDerivation {
|
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 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 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"}\" " \
|
--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}'' }
|
${optionalString withRuby '' --suffix PATH : ${rubyEnv}/bin --set GEM_HOME ${rubyEnv}/${rubyEnv.ruby.gemPath}'' }
|
||||||
|
|
||||||
''
|
''
|
||||||
@ -75,9 +76,9 @@ let
|
|||||||
--replace 'Name=Neovim' 'Name=WrappedNeovim'
|
--replace 'Name=Neovim' 'Name=WrappedNeovim'
|
||||||
''
|
''
|
||||||
+ optionalString withPython ''
|
+ optionalString withPython ''
|
||||||
ln -s ${pythonEnv}/bin/python $out/bin/nvim-python
|
makeWrapper ${pythonEnv}/bin/python $out/bin/nvim-python --unset PYTHONPATH
|
||||||
'' + optionalString withPython3 ''
|
'' + optionalString withPython3 ''
|
||||||
ln -s ${python3Env}/bin/python3 $out/bin/nvim-python3
|
makeWrapper ${python3Env}/bin/python3 $out/bin/nvim-python3 --unset PYTHONPATH
|
||||||
'' + optionalString withRuby ''
|
'' + optionalString withRuby ''
|
||||||
ln -s ${rubyEnv}/bin/neovim-ruby-host $out/bin/nvim-ruby
|
ln -s ${rubyEnv}/bin/neovim-ruby-host $out/bin/nvim-ruby
|
||||||
''
|
''
|
||||||
@ -88,7 +89,7 @@ let
|
|||||||
ln -s $out/bin/nvim $out/bin/vim
|
ln -s $out/bin/nvim $out/bin/vim
|
||||||
'' + optionalString viAlias ''
|
'' + optionalString viAlias ''
|
||||||
ln -s $out/bin/nvim $out/bin/vi
|
ln -s $out/bin/nvim $out/bin/vi
|
||||||
'' + optionalString (configure != null) ''
|
'' + optionalString (configure != {}) ''
|
||||||
wrapProgram $out/bin/nvim --add-flags "-u ${vimUtils.vimrcFile configure}"
|
wrapProgram $out/bin/nvim --add-flags "-u ${vimUtils.vimrcFile configure}"
|
||||||
''
|
''
|
||||||
;
|
;
|
||||||
|
@ -1004,7 +1004,7 @@ self = rec {
|
|||||||
sha256 = "03sr53680kcwxaa5xbqzdfbsgday3bkzja33wym49w9gjmlaa320";
|
sha256 = "03sr53680kcwxaa5xbqzdfbsgday3bkzja33wym49w9gjmlaa320";
|
||||||
};
|
};
|
||||||
dependencies = ["vimproc" "vimshell" "self" "forms"];
|
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
|
supertab = buildVimPluginFrom2Nix { # created by nix#NixDerivation
|
||||||
|
@ -280,6 +280,7 @@ let
|
|||||||
installPhase = lib.concatStringsSep
|
installPhase = lib.concatStringsSep
|
||||||
"\n"
|
"\n"
|
||||||
(lib.flatten (lib.mapAttrsToList packageLinks packages));
|
(lib.flatten (lib.mapAttrsToList packageLinks packages));
|
||||||
|
preferLocalBuild = true;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
in
|
in
|
||||||
@ -423,6 +424,7 @@ rec {
|
|||||||
} // a);
|
} // a);
|
||||||
|
|
||||||
requiredPlugins = {
|
requiredPlugins = {
|
||||||
|
packages ? {},
|
||||||
givenKnownPlugins ? null,
|
givenKnownPlugins ? null,
|
||||||
vam ? null,
|
vam ? null,
|
||||||
pathogen ? null, ...
|
pathogen ? null, ...
|
||||||
@ -437,8 +439,12 @@ rec {
|
|||||||
vamNames = findDependenciesRecursively { inherit knownPlugins; names = lib.concatMap toNames vam.pluginDictionaries; };
|
vamNames = findDependenciesRecursively { inherit knownPlugins; names = lib.concatMap toNames vam.pluginDictionaries; };
|
||||||
names = (lib.optionals (pathogen != null) pathogenNames) ++
|
names = (lib.optionals (pathogen != null) pathogenNames) ++
|
||||||
(lib.optionals (vam != null) vamNames);
|
(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
|
in
|
||||||
map (name: knownPlugins.${name}) names;
|
nativePlugins ++ nonNativePlugins;
|
||||||
|
|
||||||
|
|
||||||
# test cases:
|
# test cases:
|
||||||
test_vim_with_vim_addon_nix_using_vam = vim_configurable.customize {
|
test_vim_with_vim_addon_nix_using_vam = vim_configurable.customize {
|
||||||
|
@ -1 +1 @@
|
|||||||
pythonDependencies = with pythonPackages; [ sexpdata websocket_client ];
|
passthru.python3Dependencies = ps: with ps; [ sexpdata websocket_client ];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user