From 039fc793c35f5ea92a13a8a33a6f7edcd7b289f9 Mon Sep 17 00:00:00 2001 From: oxalica Date: Sun, 15 Aug 2021 20:09:40 +0800 Subject: [PATCH] vim_configurable: handle python3Dependencies --- pkgs/misc/vim-plugins/vim-utils.nix | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/pkgs/misc/vim-plugins/vim-utils.nix b/pkgs/misc/vim-plugins/vim-utils.nix index ca5381c59724..2f81820fe77e 100644 --- a/pkgs/misc/vim-plugins/vim-utils.nix +++ b/pkgs/misc/vim-plugins/vim-utils.nix @@ -3,6 +3,7 @@ , nix-prefetch-hg, nix-prefetch-git , fetchFromGitHub, runtimeShell , hasLuaModule +, python3 }: /* @@ -210,13 +211,24 @@ let # and can simply pass `null`. depsOfOptionalPlugins = lib.subtractLists opt (findDependenciesRecursively opt); startWithDeps = findDependenciesRecursively start; + allPlugins = lib.unique (startWithDeps ++ depsOfOptionalPlugins); + python3Env = python3.withPackages (ps: + lib.flatten (builtins.map (plugin: (plugin.python3Dependencies or (_: [])) ps) allPlugins) + ); in [ "mkdir -p $out/pack/${packageName}/start" ] # To avoid confusion, even dependencies of optional plugins are added # to `start` (except if they are explicitly listed as optional plugins). - ++ (builtins.map (x: link x packageName "start") (lib.unique (startWithDeps ++ depsOfOptionalPlugins))) + ++ (builtins.map (x: link x packageName "start") allPlugins) ++ ["mkdir -p $out/pack/${packageName}/opt"] ++ (builtins.map (x: link x packageName "opt") opt) + # Assemble all python3 dependencies into a single `site-packages` to avoid doing recursive dependency collection + # for each plugin. + # This directory is only for python import search path, and will not slow down the startup time. + ++ [ + "mkdir -p $out/pack/${packageName}/start/__python3_dependencies" + "ln -s ${python3Env}/${python3Env.sitePackages} $out/pack/${packageName}/start/__python3_dependencies/python3" + ] ); packDir = (packages: stdenv.mkDerivation {