Skip to content

Commit fb5f41b

Browse files
committedNov 20, 2017
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).
1 parent 54c281f commit fb5f41b

File tree

3 files changed

+36
-19
lines changed

3 files changed

+36
-19
lines changed
 

‎pkgs/applications/editors/neovim/default.nix

+22-15
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{ stdenv, fetchFromGitHub, cmake, gettext, libmsgpack, libtermkey
22
, libtool, libuv, luaPackages, ncurses, perl, pkgconfig
3-
, unibilium, makeWrapper, vimUtils, xsel, gperf
3+
, unibilium, makeWrapper, vimUtils, xsel, gperf, callPackage
44

55
, withPython ? true, pythonPackages, extraPythonPackages ? []
66
, withPython3 ? true, python3Packages, extraPython3Packages ? []
77
, withJemalloc ? true, jemalloc
8-
, withRuby ? true, bundlerEnv
8+
, withRuby ? true, bundlerEnv, ruby
99

1010
, withPyGUI ? false
1111
, vimAlias ? false
@@ -48,10 +48,11 @@ let
4848
rubyEnv = bundlerEnv {
4949
name = "neovim-ruby-env";
5050
gemdir = ./ruby_provider;
51+
postBuild = ''
52+
ln -s ${ruby}/bin/* $out/bin
53+
'';
5154
};
52-
53-
rubyWrapper = ''--suffix PATH : \"${rubyEnv}/bin\" '' +
54-
''--suffix GEM_HOME : \"${rubyEnv}/${rubyEnv.ruby.gemPath}\" '';
55+
rubyWrapper = ''--cmd \"let g:ruby_host_prog='$out/bin/nvim-ruby'\" '';
5556

5657
pluginPythonPackages = if configure == null then [] else builtins.concatLists
5758
(map ({ pythonDependencies ? [], ...}: pythonDependencies)
@@ -74,10 +75,14 @@ let
7475
ignoreCollisions = true;
7576
};
7677
python3Wrapper = ''--cmd \"let g:python3_host_prog='$out/bin/nvim-python3'\" '';
77-
pythonFlags = optionalString (withPython || withPython3) ''--add-flags "${
78-
(optionalString withPython pythonWrapper) +
79-
(optionalString withPython3 python3Wrapper)
80-
}"'';
78+
79+
additionalFlags =
80+
optionalString (withPython || withPython3 || withRuby)
81+
''--add-flags "${(optionalString withPython pythonWrapper) +
82+
(optionalString withPython3 python3Wrapper) +
83+
(optionalString withRuby rubyWrapper)}" --unset PYTHONPATH '' +
84+
optionalString (withRuby)
85+
''--suffix PATH : \"${rubyEnv}/bin\" --set GEM_HOME \"${rubyEnv}/${rubyEnv.ruby.gemPath}\" '';
8186

8287
neovim = stdenv.mkDerivation rec {
8388
name = "neovim-${version}";
@@ -128,21 +133,23 @@ let
128133
substituteInPlace src/nvim/CMakeLists.txt --replace " util" ""
129134
'';
130135

131-
postInstall = stdenv.lib.optionalString stdenv.isDarwin ''
132-
echo patching $out/bin/nvim
136+
postInstall = stdenv.lib.optionalString stdenv.isLinux ''
137+
sed -i -e "s|'xsel|'${xsel}/bin/xsel|" $out/share/nvim/runtime/autoload/provider/clipboard.vim
138+
'' + stdenv.lib.optionalString (withJemalloc && stdenv.isDarwin) ''
133139
install_name_tool -change libjemalloc.1.dylib \
134140
${jemalloc}/lib/libjemalloc.1.dylib \
135141
$out/bin/nvim
136-
sed -i -e "s|'xsel|'${xsel}/bin/xsel|" $out/share/nvim/runtime/autoload/provider/clipboard.vim
137142
'' + optionalString withPython ''
138143
ln -s ${pythonEnv}/bin/python $out/bin/nvim-python
144+
'' + optionalString withPython3 ''
145+
ln -s ${python3Env}/bin/python3 $out/bin/nvim-python3
146+
'' + optionalString withPython3 ''
147+
ln -s ${rubyEnv}/bin/neovim-ruby-host $out/bin/nvim-ruby
139148
'' + optionalString withPyGUI ''
140149
makeWrapper "${pythonEnv}/bin/pynvim" "$out/bin/pynvim" \
141150
--prefix PATH : "$out/bin"
142-
'' + optionalString withPython3 ''
143-
ln -s ${python3Env}/bin/python3 $out/bin/nvim-python3
144151
'' + optionalString (withPython || withPython3 || withRuby) ''
145-
wrapProgram $out/bin/nvim ${rubyWrapper + pythonFlags}
152+
wrapProgram $out/bin/nvim ${additionalFlags}
146153
'';
147154

148155
meta = {

‎pkgs/applications/editors/neovim/ruby_provider/Gemfile.lock

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@ GEM
22
remote: https://rubygems.org/
33
specs:
44
msgpack (1.1.0)
5-
neovim (0.5.1)
5+
multi_json (1.12.2)
6+
neovim (0.6.1)
67
msgpack (~> 1.0)
8+
multi_json (~> 1.0)
79

810
PLATFORMS
911
ruby

‎pkgs/applications/editors/neovim/ruby_provider/gemset.nix

+11-3
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,21 @@
77
};
88
version = "1.1.0";
99
};
10+
multi_json = {
11+
source = {
12+
remotes = ["https://rubygems.org"];
13+
sha256 = "1raim9ddjh672m32psaa9niw67ywzjbxbdb8iijx3wv9k5b0pk2x";
14+
type = "gem";
15+
};
16+
version = "1.12.2";
17+
};
1018
neovim = {
11-
dependencies = ["msgpack"];
19+
dependencies = ["msgpack" "multi_json"];
1220
source = {
1321
remotes = ["https://rubygems.org"];
14-
sha256 = "08xn7r4g13wl4bhvkmp4hx3x0ppvifs1x2iiqh8jl9f1jb4jhfcp";
22+
sha256 = "1dnv2pdl8lwwy4av8bqc6kdlgxw88dmajm4fkdk6hc7qdx1sw234";
1523
type = "gem";
1624
};
17-
version = "0.5.1";
25+
version = "0.6.1";
1826
};
1927
}

0 commit comments

Comments
 (0)
Please sign in to comment.