From c1752666dfb1f47bf18225524c695621978d1419 Mon Sep 17 00:00:00 2001 From: Symphorien Gibol Date: Wed, 11 Jul 2018 22:57:26 +0200 Subject: neovim wrapper: use python.withPackages instead of python.buildEnv They are both as powerful, but buildEnv is treacherous: if you pass a package which depends on another python (for example the one of unstable when you are on stable) it will be *silently* dropped, leading to hair pulling. Use case: override neovim from unstable, but still keep stable's pythonPackages. --- pkgs/applications/editors/neovim/wrapper.nix | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'pkgs') diff --git a/pkgs/applications/editors/neovim/wrapper.nix b/pkgs/applications/editors/neovim/wrapper.nix index a57831ba03c0..90b7f1ae7bea 100644 --- a/pkgs/applications/editors/neovim/wrapper.nix +++ b/pkgs/applications/editors/neovim/wrapper.nix @@ -10,8 +10,8 @@ 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 @@ -28,25 +28,25 @@ let ''; }; + /* 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; + 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; - }; + pythonEnv = pythonPackages.python.withPackages(ps: + (if withPyGUI then [ ps.neovim_gui ] else [ ps.neovim ]) + ++ (extraPythonPackagesFun ps) ++ pluginPythonPackages); 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; - }; + python3Env = python3Packages.python.withPackages (ps: + [ ps.neovim ] ++ (extraPython3PackagesFun ps) ++ pluginPython3Packages); in stdenv.mkDerivation { -- cgit 1.4.1