From fb5f41bb00534c1a21bb9a516907069752483403 Mon Sep 17 00:00:00 2001 From: Rok Garbas Date: Thu, 16 Nov 2017 03:34:01 +0100 Subject: [PATCH] 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). --- pkgs/applications/editors/neovim/default.nix | 37 +++++++++++-------- .../editors/neovim/ruby_provider/Gemfile.lock | 4 +- .../editors/neovim/ruby_provider/gemset.nix | 16 ++++++-- 3 files changed, 37 insertions(+), 20 deletions(-) diff --git a/pkgs/applications/editors/neovim/default.nix b/pkgs/applications/editors/neovim/default.nix index cc6e8f005e76..ba3abe6a221f 100644 --- a/pkgs/applications/editors/neovim/default.nix +++ b/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 @@ -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) @@ -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}"; @@ -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 = { diff --git a/pkgs/applications/editors/neovim/ruby_provider/Gemfile.lock b/pkgs/applications/editors/neovim/ruby_provider/Gemfile.lock index dcb79095aa67..61df9ed79323 100644 --- a/pkgs/applications/editors/neovim/ruby_provider/Gemfile.lock +++ b/pkgs/applications/editors/neovim/ruby_provider/Gemfile.lock @@ -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 diff --git a/pkgs/applications/editors/neovim/ruby_provider/gemset.nix b/pkgs/applications/editors/neovim/ruby_provider/gemset.nix index 9d0ecb2788ed..85bff42b64dd 100644 --- a/pkgs/applications/editors/neovim/ruby_provider/gemset.nix +++ b/pkgs/applications/editors/neovim/ruby_provider/gemset.nix @@ -7,13 +7,21 @@ }; version = "1.1.0"; }; - neovim = { - dependencies = ["msgpack"]; + multi_json = { source = { remotes = ["https://rubygems.org"]; - sha256 = "08xn7r4g13wl4bhvkmp4hx3x0ppvifs1x2iiqh8jl9f1jb4jhfcp"; + sha256 = "1raim9ddjh672m32psaa9niw67ywzjbxbdb8iijx3wv9k5b0pk2x"; 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"; }; } \ No newline at end of file