From f2d7f573af9063a3a484c80e426490e5093afe32 Mon Sep 17 00:00:00 2001 From: Rok Garbas Date: Thu, 11 Jun 2015 02:42:20 +0200 Subject: [PATCH] neovim: adding python2 and python3 support neovim: - possibility to extend neovim (via .override) and passing extraPythonPackages or extraPython3Packages - neovim's python interpreter can be found as nvim-python / nvim-python3 - wrapping nvim binary and setting `g:python_host_prog` and `g:python3_host_prog` via --cmd flag python-packages.nix fixes: - ordereddict builds for py26 and uses disabled argument to tell this - trollius builds on all python platforms except 3.4 (where is included in standard librarary) - neovim builds on all python platforms --- pkgs/applications/editors/neovim/default.nix | 61 +++++++++++++++----- pkgs/top-level/python-packages.nix | 37 +++++++----- 2 files changed, 71 insertions(+), 27 deletions(-) diff --git a/pkgs/applications/editors/neovim/default.nix b/pkgs/applications/editors/neovim/default.nix index 814b05ced364..e2dbc4abc56d 100644 --- a/pkgs/applications/editors/neovim/default.nix +++ b/pkgs/applications/editors/neovim/default.nix @@ -1,18 +1,16 @@ { stdenv, fetchFromGitHub, cmake, gettext, glib, libmsgpack , libtermkey, libtool, libuv, lpeg, lua, luajit, luaMessagePack -, luabitop, ncurses, perl, pkgconfig, unibilium -, withJemalloc ? true, jemalloc }: +, luabitop, ncurses, perl, pkgconfig, unibilium, makeWrapper +, withPython ? true, pythonPackages, extraPythonPackages ? [] +, withPython3 ? true, python3Packages, extraPython3Packages ? [] +, withJemalloc ? true, jemalloc +}: -let version = "2015-06-09"; in -stdenv.mkDerivation rec { - name = "neovim-${version}"; +with stdenv.lib; - src = fetchFromGitHub { - sha256 = "1lycql0lwi7ynrsaln4kxybwvxb9fvganiq3ba4pnpcfgl155k1j"; - rev = "6270d431aaeed71e7a8782411f36409ab8e0ee35"; - repo = "neovim"; - owner = "neovim"; - }; +let + + version = "2015-06-09"; # Note: this is NOT the libvterm already in nixpkgs, but some NIH silliness: neovimLibvterm = let version = "2015-02-23"; in stdenv.mkDerivation rec { @@ -31,7 +29,7 @@ stdenv.mkDerivation rec { enableParallelBuilding = true; - meta = with stdenv.lib; { + meta = { description = "VT220/xterm/ECMA-48 terminal emulator library"; homepage = http://www.leonerd.org.uk/code/libvterm/; license = licenses.mit; @@ -40,9 +38,30 @@ stdenv.mkDerivation rec { }; }; + pythonEnv = pythonPackages.python.buildEnv.override { + extraLibs = [ pythonPackages.neovim ] ++ extraPythonPackages; + ignoreCollisions = true; + }; + + python3Env = python3Packages.python.buildEnv.override { + extraLibs = [ python3Packages.neovim ] ++ extraPython3Packages; + ignoreCollisions = true; + }; + +in stdenv.mkDerivation rec { + name = "neovim-${version}"; + + src = fetchFromGitHub { + sha256 = "1lycql0lwi7ynrsaln4kxybwvxb9fvganiq3ba4pnpcfgl155k1j"; + rev = "6270d431aaeed71e7a8782411f36409ab8e0ee35"; + repo = "neovim"; + owner = "neovim"; + }; + enableParallelBuilding = true; buildInputs = [ + makeWrapper cmake glib libtermkey @@ -57,7 +76,8 @@ stdenv.mkDerivation rec { neovimLibvterm pkgconfig unibilium - ] ++ stdenv.lib.optional withJemalloc jemalloc; + ] ++ optional withJemalloc jemalloc; + nativeBuildInputs = [ gettext ]; @@ -65,7 +85,20 @@ stdenv.mkDerivation rec { LUA_CPATH="${lpeg}/lib/lua/${lua.luaversion}/?.so;${luabitop}/lib/lua/5.2/?.so"; LUA_PATH="${luaMessagePack}/share/lua/5.1/?.lua"; - meta = with stdenv.lib; { + postInstall = optionalString withPython '' + ln -s ${pythonEnv}/bin/python $out/bin/nvim-python + '' + optionalString withPython3 '' + ln -s ${python3Env}/bin/python $out/bin/nvim-python3 + '' + optionalString (withPython || withPython3) '' + wrapProgram $out/bin/nvim --add-flags "${ + (optionalString withPython + ''--cmd \"let g:python_host_prog='$out/bin/nvim-python'\" '') + + (optionalString withPython3 + ''--cmd \"let g:python3_host_prog='$out/bin/nvim-python3'\"'') + }" + ''; + + meta = { description = "Vim text editor fork focused on extensibility and agility"; longDescription = '' Neovim is a project that seeks to aggressively refactor Vim in order to: diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index b47aa36f2c70..4da6cdbcf78e 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -8100,14 +8100,21 @@ let # }; # }); - ordereddict = if isPy26 then (buildPythonPackage { + ordereddict = buildPythonPackage rec { name = "ordereddict-1.1"; + disabled = !isPy26; + src = pkgs.fetchurl { - url = "http://pypi.python.org/packages/source/o/ordereddict/ordereddict-1.1.tar.gz"; + url = "http://pypi.python.org/packages/source/o/ordereddict/${name}.tar.gz"; md5 = "a0ed854ee442051b249bfad0f638bbec"; }; - doCheck = false; - }) else null; + + meta = { + description = "A drop-in substitute for Py2.7's new collections.OrderedDict that works in Python 2.4-2.6."; + license = licenses.bsd3; + maintainers = with maintainers; [ garbas ]; + }; + }; ply = buildPythonPackage (rec { name = "ply-3.4"; @@ -15775,16 +15782,23 @@ let trollius = buildPythonPackage rec { version = "1.0.4"; name = "trollius-${version}"; - disabled = ! isPy27; + disabled = isPy34; src = pkgs.fetchurl { url = "https://pypi.python.org/packages/source/t/trollius/${name}.tar.gz"; md5 = "3631a464d49d0cbfd30ab2918ef2b783"; }; - buildInputs = [ self.mock ]; + buildInputs = with self; [ mock ] + ++ optional isPy26 unittest2; - propagatedBuildInputs = [ self.futures ]; + propagatedBuildInputs = with self; [] + ++ optional isPy26 ordereddict + ++ optional (isPy26 || isPy27 || isPyPy) futures; + + patchPhase = optionalString isPy26 '' + sed -i -e "s|test_env_var_debug|skip_test_env_var_debug|" tests/test_tasks.py + ''; meta = { description = "Port of the Tulip project (asyncio module, PEP 3156) on Python 2"; @@ -15797,18 +15811,15 @@ let neovim = buildPythonPackage rec { version = "0.0.36"; name = "neovim-${version}"; - disabled = ! isPy27; src = pkgs.fetchurl { url = "https://pypi.python.org/packages/source/n/neovim/${name}.tar.gz"; md5 = "8cdad23402e29c7c5a1e85770e976edf"; }; - propagatedBuildInputs = with self; [ - msgpack - trollius - greenlet - ]; + propagatedBuildInputs = with self; [ msgpack ] + ++ optional (!isPyPy) greenlet + ++ optional (!isPy34) trollius; meta = { description = "Python client for Neovim";