Skip to content

Commit

Permalink
neovim: ruby and python isolation
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
garbas committed Nov 20, 2017
1 parent 54c281f commit fb5f41b
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 19 deletions.
37 changes: 22 additions & 15 deletions pkgs/applications/editors/neovim/default.nix
@@ -1,11 +1,11 @@
{ stdenv, fetchFromGitHub, cmake, gettext, libmsgpack, libtermkey
, libtool, libuv, luaPackages, ncurses, perl, pkgconfig
, unibilium, makeWrapper, vimUtils, xsel, gperf
, unibilium, makeWrapper, vimUtils, xsel, gperf, callPackage

, withPython ? true, pythonPackages, extraPythonPackages ? []
, withPython3 ? true, python3Packages, extraPython3Packages ? []
, withJemalloc ? true, jemalloc
, withRuby ? true, bundlerEnv
, withRuby ? true, bundlerEnv, ruby

, withPyGUI ? false
, vimAlias ? false
Expand Down Expand Up @@ -48,10 +48,11 @@ let
rubyEnv = bundlerEnv {
name = "neovim-ruby-env";
gemdir = ./ruby_provider;
postBuild = ''
ln -s ${ruby}/bin/* $out/bin
'';
};

rubyWrapper = ''--suffix PATH : \"${rubyEnv}/bin\" '' +
''--suffix GEM_HOME : \"${rubyEnv}/${rubyEnv.ruby.gemPath}\" '';
rubyWrapper = ''--cmd \"let g:ruby_host_prog='$out/bin/nvim-ruby'\" '';

pluginPythonPackages = if configure == null then [] else builtins.concatLists
(map ({ pythonDependencies ? [], ...}: pythonDependencies)
Expand All @@ -74,10 +75,14 @@ let
ignoreCollisions = true;
};
python3Wrapper = ''--cmd \"let g:python3_host_prog='$out/bin/nvim-python3'\" '';
pythonFlags = optionalString (withPython || withPython3) ''--add-flags "${
(optionalString withPython pythonWrapper) +
(optionalString withPython3 python3Wrapper)
}"'';

additionalFlags =
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 {
name = "neovim-${version}";
Expand Down Expand Up @@ -128,21 +133,23 @@ let
substituteInPlace src/nvim/CMakeLists.txt --replace " util" ""
'';

postInstall = stdenv.lib.optionalString stdenv.isDarwin ''
echo patching $out/bin/nvim
postInstall = stdenv.lib.optionalString stdenv.isLinux ''
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 \
${jemalloc}/lib/libjemalloc.1.dylib \
$out/bin/nvim
sed -i -e "s|'xsel|'${xsel}/bin/xsel|" $out/share/nvim/runtime/autoload/provider/clipboard.vim
'' + optionalString withPython ''
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 ''
makeWrapper "${pythonEnv}/bin/pynvim" "$out/bin/pynvim" \
--prefix PATH : "$out/bin"
'' + optionalString withPython3 ''
ln -s ${python3Env}/bin/python3 $out/bin/nvim-python3
'' + optionalString (withPython || withPython3 || withRuby) ''
wrapProgram $out/bin/nvim ${rubyWrapper + pythonFlags}
wrapProgram $out/bin/nvim ${additionalFlags}
'';

meta = {
Expand Down
4 changes: 3 additions & 1 deletion pkgs/applications/editors/neovim/ruby_provider/Gemfile.lock
Expand Up @@ -2,8 +2,10 @@ GEM
remote: https://rubygems.org/
specs:
msgpack (1.1.0)
neovim (0.5.1)
multi_json (1.12.2)
neovim (0.6.1)
msgpack (~> 1.0)
multi_json (~> 1.0)

PLATFORMS
ruby
Expand Down
14 changes: 11 additions & 3 deletions pkgs/applications/editors/neovim/ruby_provider/gemset.nix
Expand Up @@ -7,13 +7,21 @@
};
version = "1.1.0";
};
multi_json = {
source = {
remotes = ["https://rubygems.org"];
sha256 = "1raim9ddjh672m32psaa9niw67ywzjbxbdb8iijx3wv9k5b0pk2x";
type = "gem";
};
version = "1.12.2";
};
neovim = {
dependencies = ["msgpack"];
dependencies = ["msgpack" "multi_json"];
source = {
remotes = ["https://rubygems.org"];
sha256 = "08xn7r4g13wl4bhvkmp4hx3x0ppvifs1x2iiqh8jl9f1jb4jhfcp";
sha256 = "1dnv2pdl8lwwy4av8bqc6kdlgxw88dmajm4fkdk6hc7qdx1sw234";
type = "gem";
};
version = "0.5.1";
version = "0.6.1";
};
}

0 comments on commit fb5f41b

Please sign in to comment.