neovim: ruby and python isolation

the code has been taken from #31604 and fixed so that :CheckHealth for
ruby provider is also green (ruby and gem are required to be in PATH).
This commit is contained in:
Rok Garbas 2017-11-16 03:34:01 +01:00
parent 54c281fa39
commit fb5f41bb00
3 changed files with 37 additions and 20 deletions

View File

@ -1,11 +1,11 @@
{ stdenv, fetchFromGitHub, cmake, gettext, libmsgpack, libtermkey { stdenv, fetchFromGitHub, cmake, gettext, libmsgpack, libtermkey
, libtool, libuv, luaPackages, ncurses, perl, pkgconfig , libtool, libuv, luaPackages, ncurses, perl, pkgconfig
, unibilium, makeWrapper, vimUtils, xsel, gperf , unibilium, makeWrapper, vimUtils, xsel, gperf, callPackage
, withPython ? true, pythonPackages, extraPythonPackages ? [] , withPython ? true, pythonPackages, extraPythonPackages ? []
, withPython3 ? true, python3Packages, extraPython3Packages ? [] , withPython3 ? true, python3Packages, extraPython3Packages ? []
, withJemalloc ? true, jemalloc , withJemalloc ? true, jemalloc
, withRuby ? true, bundlerEnv , withRuby ? true, bundlerEnv, ruby
, withPyGUI ? false , withPyGUI ? false
, vimAlias ? false , vimAlias ? false
@ -48,10 +48,11 @@ let
rubyEnv = bundlerEnv { rubyEnv = bundlerEnv {
name = "neovim-ruby-env"; name = "neovim-ruby-env";
gemdir = ./ruby_provider; gemdir = ./ruby_provider;
postBuild = ''
ln -s ${ruby}/bin/* $out/bin
'';
}; };
rubyWrapper = ''--cmd \"let g:ruby_host_prog='$out/bin/nvim-ruby'\" '';
rubyWrapper = ''--suffix PATH : \"${rubyEnv}/bin\" '' +
''--suffix GEM_HOME : \"${rubyEnv}/${rubyEnv.ruby.gemPath}\" '';
pluginPythonPackages = if configure == null then [] else builtins.concatLists pluginPythonPackages = if configure == null then [] else builtins.concatLists
(map ({ pythonDependencies ? [], ...}: pythonDependencies) (map ({ pythonDependencies ? [], ...}: pythonDependencies)
@ -74,10 +75,14 @@ let
ignoreCollisions = true; ignoreCollisions = true;
}; };
python3Wrapper = ''--cmd \"let g:python3_host_prog='$out/bin/nvim-python3'\" ''; python3Wrapper = ''--cmd \"let g:python3_host_prog='$out/bin/nvim-python3'\" '';
pythonFlags = optionalString (withPython || withPython3) ''--add-flags "${
(optionalString withPython pythonWrapper) + additionalFlags =
(optionalString withPython3 python3Wrapper) optionalString (withPython || withPython3 || withRuby)
}"''; ''--add-flags "${(optionalString withPython pythonWrapper) +
(optionalString withPython3 python3Wrapper) +
(optionalString withRuby rubyWrapper)}" --unset PYTHONPATH '' +
optionalString (withRuby)
''--suffix PATH : \"${rubyEnv}/bin\" --set GEM_HOME \"${rubyEnv}/${rubyEnv.ruby.gemPath}\" '';
neovim = stdenv.mkDerivation rec { neovim = stdenv.mkDerivation rec {
name = "neovim-${version}"; name = "neovim-${version}";
@ -128,21 +133,23 @@ let
substituteInPlace src/nvim/CMakeLists.txt --replace " util" "" substituteInPlace src/nvim/CMakeLists.txt --replace " util" ""
''; '';
postInstall = stdenv.lib.optionalString stdenv.isDarwin '' postInstall = stdenv.lib.optionalString stdenv.isLinux ''
echo patching $out/bin/nvim sed -i -e "s|'xsel|'${xsel}/bin/xsel|" $out/share/nvim/runtime/autoload/provider/clipboard.vim
'' + stdenv.lib.optionalString (withJemalloc && stdenv.isDarwin) ''
install_name_tool -change libjemalloc.1.dylib \ install_name_tool -change libjemalloc.1.dylib \
${jemalloc}/lib/libjemalloc.1.dylib \ ${jemalloc}/lib/libjemalloc.1.dylib \
$out/bin/nvim $out/bin/nvim
sed -i -e "s|'xsel|'${xsel}/bin/xsel|" $out/share/nvim/runtime/autoload/provider/clipboard.vim
'' + optionalString withPython '' '' + optionalString withPython ''
ln -s ${pythonEnv}/bin/python $out/bin/nvim-python ln -s ${pythonEnv}/bin/python $out/bin/nvim-python
'' + optionalString withPython3 ''
ln -s ${python3Env}/bin/python3 $out/bin/nvim-python3
'' + optionalString withPython3 ''
ln -s ${rubyEnv}/bin/neovim-ruby-host $out/bin/nvim-ruby
'' + optionalString withPyGUI '' '' + optionalString withPyGUI ''
makeWrapper "${pythonEnv}/bin/pynvim" "$out/bin/pynvim" \ makeWrapper "${pythonEnv}/bin/pynvim" "$out/bin/pynvim" \
--prefix PATH : "$out/bin" --prefix PATH : "$out/bin"
'' + optionalString withPython3 ''
ln -s ${python3Env}/bin/python3 $out/bin/nvim-python3
'' + optionalString (withPython || withPython3 || withRuby) '' '' + optionalString (withPython || withPython3 || withRuby) ''
wrapProgram $out/bin/nvim ${rubyWrapper + pythonFlags} wrapProgram $out/bin/nvim ${additionalFlags}
''; '';
meta = { meta = {

View File

@ -2,8 +2,10 @@ GEM
remote: https://rubygems.org/ remote: https://rubygems.org/
specs: specs:
msgpack (1.1.0) msgpack (1.1.0)
neovim (0.5.1) multi_json (1.12.2)
neovim (0.6.1)
msgpack (~> 1.0) msgpack (~> 1.0)
multi_json (~> 1.0)
PLATFORMS PLATFORMS
ruby ruby

View File

@ -7,13 +7,21 @@
}; };
version = "1.1.0"; version = "1.1.0";
}; };
neovim = { multi_json = {
dependencies = ["msgpack"];
source = { source = {
remotes = ["https://rubygems.org"]; remotes = ["https://rubygems.org"];
sha256 = "08xn7r4g13wl4bhvkmp4hx3x0ppvifs1x2iiqh8jl9f1jb4jhfcp"; sha256 = "1raim9ddjh672m32psaa9niw67ywzjbxbdb8iijx3wv9k5b0pk2x";
type = "gem"; type = "gem";
}; };
version = "0.5.1"; version = "1.12.2";
};
neovim = {
dependencies = ["msgpack" "multi_json"];
source = {
remotes = ["https://rubygems.org"];
sha256 = "1dnv2pdl8lwwy4av8bqc6kdlgxw88dmajm4fkdk6hc7qdx1sw234";
type = "gem";
};
version = "0.6.1";
}; };
} }