diff options
Diffstat (limited to 'infra/libkookie/nixpkgs/pkgs/applications/editors/neovim')
11 files changed, 697 insertions, 0 deletions
diff --git a/infra/libkookie/nixpkgs/pkgs/applications/editors/neovim/default.nix b/infra/libkookie/nixpkgs/pkgs/applications/editors/neovim/default.nix new file mode 100644 index 000000000000..b546aae790a7 --- /dev/null +++ b/infra/libkookie/nixpkgs/pkgs/applications/editors/neovim/default.nix @@ -0,0 +1,141 @@ +{ stdenv, fetchFromGitHub, cmake, gettext, msgpack, libtermkey, libiconv +, libuv, lua, ncurses, pkgconfig +, unibilium, xsel, gperf +, libvterm-neovim +, glibcLocales ? null, procps ? null + +# now defaults to false because some tests can be flaky (clipboard etc) +, doCheck ? false +, nodejs ? null, fish ? null, python ? null +}: + +with stdenv.lib; + +let + neovimLuaEnv = lua.withPackages(ps: + (with ps; [ lpeg luabitop mpack ] + ++ optionals doCheck [ + nvim-client luv coxpcall busted luafilesystem penlight inspect + ] + )); + + pyEnv = python.withPackages(ps: [ ps.pynvim ps.msgpack ]); + + # FIXME: this is verry messy and strange. + # see https://github.com/NixOS/nixpkgs/pull/80528 + luv = lua.pkgs.luv; + luvpath = with builtins ; if stdenv.isDarwin + then "${luv.libluv}/lib/lua/${lua.luaversion}/libluv.${head (match "([0-9.]+).*" luv.version)}.dylib" + else "${luv}/lib/lua/${lua.luaversion}/luv.so"; + +in + stdenv.mkDerivation rec { + pname = "neovim-unwrapped"; + version = "0.4.4"; + + src = fetchFromGitHub { + owner = "neovim"; + repo = "neovim"; + rev = "v${version}"; + sha256 = "11zyj6jvkwas3n6w1ckj3pk6jf81z1g7ngg4smmwm7c27y2a6f2m"; + }; + + patches = [ + # introduce a system-wide rplugin.vim in addition to the user one + # necessary so that nix can handle `UpdateRemotePlugins` for the plugins + # it installs. See https://github.com/neovim/neovim/issues/9413. + ./system_rplugin_manifest.patch + ]; + + dontFixCmake = true; + enableParallelBuilding = true; + + buildInputs = [ + gperf + libtermkey + libuv + libvterm-neovim + luv.libluv + msgpack + ncurses + neovimLuaEnv + unibilium + ] ++ optional stdenv.isDarwin libiconv + ++ optionals doCheck [ glibcLocales procps ] + ; + + inherit doCheck; + + # to be exhaustive, one could run + # make oldtests too + checkPhase = '' + make functionaltest + ''; + + nativeBuildInputs = [ + cmake + gettext + pkgconfig + ]; + + # extra programs test via `make functionaltest` + checkInputs = [ + fish + nodejs + pyEnv # for src/clint.py + ]; + + + # nvim --version output retains compilation flags and references to build tools + postPatch = '' + substituteInPlace src/nvim/version.c --replace NVIM_VERSION_CFLAGS ""; + ''; + # check that the above patching actually works + disallowedReferences = [ stdenv.cc ]; + + cmakeFlags = [ + "-DGPERF_PRG=${gperf}/bin/gperf" + "-DLUA_PRG=${neovimLuaEnv.interpreter}" + "-DLIBLUV_LIBRARY=${luvpath}" + ] + ++ optional doCheck "-DBUSTED_PRG=${neovimLuaEnv}/bin/busted" + ++ optional (!lua.pkgs.isLuaJIT) "-DPREFER_LUA=ON" + ; + + # triggers on buffer overflow bug while running tests + hardeningDisable = [ "fortify" ]; + + preConfigure = stdenv.lib.optionalString stdenv.isDarwin '' + substituteInPlace src/nvim/CMakeLists.txt --replace " util" "" + ''; + + postInstall = stdenv.lib.optionalString stdenv.isLinux '' + sed -i -e "s|'xsel|'${xsel}/bin/xsel|g" $out/share/nvim/runtime/autoload/provider/clipboard.vim + ''; + + # export PATH=$PWD/build/bin:${PATH} + shellHook='' + export VIMRUNTIME=$PWD/runtime + ''; + + 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: + - Simplify maintenance and encourage contributions + - Split the work between multiple developers + - Enable the implementation of new/modern user interfaces without any + modifications to the core source + - Improve extensibility with a new plugin architecture + ''; + homepage = "https://www.neovim.io"; + # "Contributions committed before b17d96 by authors who did not sign the + # Contributor License Agreement (CLA) remain under the Vim license. + # Contributions committed after b17d96 are licensed under Apache 2.0 unless + # those contributions were copied from Vim (identified in the commit logs + # by the vim-patch token). See LICENSE for details." + license = with licenses; [ asl20 vim ]; + maintainers = with maintainers; [ manveru rvolosatovs ma27 ]; + platforms = platforms.unix; + }; + } diff --git a/infra/libkookie/nixpkgs/pkgs/applications/editors/neovim/gnvim/default.nix b/infra/libkookie/nixpkgs/pkgs/applications/editors/neovim/gnvim/default.nix new file mode 100644 index 000000000000..e6166dd14b19 --- /dev/null +++ b/infra/libkookie/nixpkgs/pkgs/applications/editors/neovim/gnvim/default.nix @@ -0,0 +1,50 @@ +{ stdenv, rustPlatform, fetchFromGitHub, gtk, webkitgtk }: + +rustPlatform.buildRustPackage rec { + pname = "gnvim-unwrapped"; + version = "0.1.6"; + + src = fetchFromGitHub { + owner = "vhakulinen"; + repo = "gnvim"; + rev = "v${version}"; + sha256 = "1cc3yk04v9icdjr5cn58mqc3ba1wqmlzhf9ly7biy9m8yk30w9y0"; + }; + + cargoSha256 = "1fyn8nsabzrfl9ykf2gk2p8if0yjp6k0ybrmp0pw67pbwaxpb9ym"; + + buildInputs = [ gtk webkitgtk ]; + + # The default build script tries to get the version through Git, so we + # replace it + prePatch = '' + cat << EOF > build.rs + use std::env; + use std::fs::File; + use std::io::Write; + use std::path::Path; + + fn main() { + let out_dir = env::var("OUT_DIR").unwrap(); + let dest_path = Path::new(&out_dir).join("gnvim_version.rs"); + let mut f = File::create(&dest_path).unwrap(); + f.write_all(b"const VERSION: &str = \"${version}\";").unwrap(); + } + EOF + ''; + + buildPhase = '' + make build + ''; + + installPhase = '' + make install PREFIX="${placeholder "out"}" + ''; + + meta = with stdenv.lib; { + description = "GUI for neovim, without any web bloat"; + homepage = "https://github.com/vhakulinen/gnvim"; + license = licenses.mit; + maintainers = with maintainers; [ minijackson ]; + }; +} diff --git a/infra/libkookie/nixpkgs/pkgs/applications/editors/neovim/gnvim/wrapper.nix b/infra/libkookie/nixpkgs/pkgs/applications/editors/neovim/gnvim/wrapper.nix new file mode 100644 index 000000000000..bb9930b6c718 --- /dev/null +++ b/infra/libkookie/nixpkgs/pkgs/applications/editors/neovim/gnvim/wrapper.nix @@ -0,0 +1,39 @@ +{ stdenv, gnvim-unwrapped, neovim, makeWrapper }: + +stdenv.mkDerivation { + pname = "gnvim"; + version = gnvim-unwrapped.version; + buildCommand = if stdenv.isDarwin then '' + mkdir -p $out/Applications + cp -r ${gnvim-unwrapped}/bin/gnvim.app $out/Applications + + chmod -R a+w "$out/Applications/gnvim.app/Contents/MacOS" + wrapProgram "$out/Applications/gnvim.app/Contents/MacOS/gnvim" \ + --prefix PATH : "${neovim}/bin" \ + --set GNVIM_RUNTIME_PATH "${gnvim-unwrapped}/share/gnvim/runtime" + '' else '' + makeWrapper '${gnvim-unwrapped}/bin/gnvim' "$out/bin/gnvim" \ + --prefix PATH : "${neovim}/bin" \ + --set GNVIM_RUNTIME_PATH "${gnvim-unwrapped}/share/gnvim/runtime" + + mkdir -p "$out/share" + ln -s '${gnvim-unwrapped}/share/icons' "$out/share/icons" + + # copy and fix .desktop file + cp -r '${gnvim-unwrapped}/share/applications' "$out/share/applications" + # Sed needs a writable directory to do inplace modifications + chmod u+rw "$out/share/applications" + sed -e "s|Exec=.\\+gnvim\\>|Exec=gnvim|" -i $out/share/applications/*.desktop + ''; + + preferLocalBuild = true; + + nativeBuildInputs = [ + makeWrapper + ]; + + passthru.unwrapped = gnvim-unwrapped; + + inherit (gnvim-unwrapped) meta; +} + diff --git a/infra/libkookie/nixpkgs/pkgs/applications/editors/neovim/neovim-remote.nix b/infra/libkookie/nixpkgs/pkgs/applications/editors/neovim/neovim-remote.nix new file mode 100644 index 000000000000..06beff03f904 --- /dev/null +++ b/infra/libkookie/nixpkgs/pkgs/applications/editors/neovim/neovim-remote.nix @@ -0,0 +1,30 @@ +{ stdenv, fetchFromGitHub, pythonPackages }: + +with stdenv.lib; + +pythonPackages.buildPythonApplication rec { + pname = "neovim-remote"; + version = "2.4.0"; + disabled = !pythonPackages.isPy3k; + + src = fetchFromGitHub { + owner = "mhinz"; + repo = "neovim-remote"; + rev = "v${version}"; + sha256 = "0jlw0qksak4bdzddpsj74pm2f2bgpj3cwrlspdjjy0j9qzg0mpl9"; + }; + + propagatedBuildInputs = with pythonPackages; [ + pynvim + psutil + setuptools + ]; + + meta = { + description = "A tool that helps controlling nvim processes from a terminal"; + homepage = "https://github.com/mhinz/neovim-remote/"; + license = licenses.mit; + maintainers = with maintainers; [ edanaher ]; + platforms = platforms.unix; + }; +} diff --git a/infra/libkookie/nixpkgs/pkgs/applications/editors/neovim/qt.nix b/infra/libkookie/nixpkgs/pkgs/applications/editors/neovim/qt.nix new file mode 100644 index 000000000000..323f08c23f87 --- /dev/null +++ b/infra/libkookie/nixpkgs/pkgs/applications/editors/neovim/qt.nix @@ -0,0 +1,81 @@ +{ stdenv, mkDerivation, fetchFromGitHub, cmake, doxygen, makeWrapper +, msgpack, neovim, pythonPackages, qtbase }: + +let + unwrapped = mkDerivation rec { + pname = "neovim-qt-unwrapped"; + version = "0.2.16.1"; + + src = fetchFromGitHub { + owner = "equalsraf"; + repo = "neovim-qt"; + rev = "v${version}"; + sha256 = "0x5brrim3f21bzdmh6wyrhrislwpx1248wbx56csvic6v78hzqny"; + }; + + cmakeFlags = [ + "-DUSE_SYSTEM_MSGPACK=1" + "-DENABLE_TESTS=0" # tests fail because xcb platform plugin is not found + ]; + + buildInputs = [ + neovim.unwrapped # only used to generate help tags at build time + qtbase + ] ++ (with pythonPackages; [ + jinja2 python msgpack + ]); + + nativeBuildInputs = [ cmake doxygen ]; + + enableParallelBuilding = true; + + preCheck = '' + # The GUI tests require a running X server, disable them + sed -i ../test/CMakeLists.txt \ + -e '/^add_xtest_gui/d' + ''; + + doCheck = true; + + meta = with stdenv.lib; { + description = "Neovim client library and GUI, in Qt5"; + homepage = "https://github.com/equalsraf/neovim-qt"; + license = licenses.isc; + maintainers = with maintainers; [ peterhoeg ]; + inherit (neovim.meta) platforms; + inherit version; + }; + }; +in + stdenv.mkDerivation { + pname = "neovim-qt"; + version = unwrapped.version; + buildCommand = if stdenv.isDarwin then '' + mkdir -p $out/Applications + cp -r ${unwrapped}/bin/nvim-qt.app $out/Applications + + chmod -R a+w "$out/Applications/nvim-qt.app/Contents/MacOS" + wrapProgram "$out/Applications/nvim-qt.app/Contents/MacOS/nvim-qt" \ + --prefix PATH : "${neovim}/bin" + '' else '' + makeWrapper '${unwrapped}/bin/nvim-qt' "$out/bin/nvim-qt" \ + --prefix PATH : "${neovim}/bin" + + # link .desktop file + mkdir -p "$out/share/pixmaps" + ln -s '${unwrapped}/share/applications' "$out/share/applications" + ln -s '${unwrapped}/share/pixmaps/nvim-qt.png' "$out/share/pixmaps/nvim-qt.png" + ''; + + preferLocalBuild = true; + + nativeBuildInputs = [ + makeWrapper + ]; + + passthru = { + inherit unwrapped; + }; + + inherit (unwrapped) meta; + } diff --git a/infra/libkookie/nixpkgs/pkgs/applications/editors/neovim/ruby_provider/Gemfile b/infra/libkookie/nixpkgs/pkgs/applications/editors/neovim/ruby_provider/Gemfile new file mode 100644 index 000000000000..eebecf2906fb --- /dev/null +++ b/infra/libkookie/nixpkgs/pkgs/applications/editors/neovim/ruby_provider/Gemfile @@ -0,0 +1,3 @@ +source 'https://rubygems.org' + +gem 'neovim' diff --git a/infra/libkookie/nixpkgs/pkgs/applications/editors/neovim/ruby_provider/Gemfile.lock b/infra/libkookie/nixpkgs/pkgs/applications/editors/neovim/ruby_provider/Gemfile.lock new file mode 100644 index 000000000000..d0827bf2a7ff --- /dev/null +++ b/infra/libkookie/nixpkgs/pkgs/applications/editors/neovim/ruby_provider/Gemfile.lock @@ -0,0 +1,17 @@ +GEM + remote: https://rubygems.org/ + specs: + msgpack (1.2.6) + multi_json (1.13.1) + neovim (0.8.0) + msgpack (~> 1.1) + multi_json (~> 1.0) + +PLATFORMS + ruby + +DEPENDENCIES + neovim + +BUNDLED WITH + 2.1.4 diff --git a/infra/libkookie/nixpkgs/pkgs/applications/editors/neovim/ruby_provider/gemset.nix b/infra/libkookie/nixpkgs/pkgs/applications/editors/neovim/ruby_provider/gemset.nix new file mode 100644 index 000000000000..28a53cc590f6 --- /dev/null +++ b/infra/libkookie/nixpkgs/pkgs/applications/editors/neovim/ruby_provider/gemset.nix @@ -0,0 +1,27 @@ +{ + msgpack = { + source = { + remotes = ["https://rubygems.org"]; + sha256 = "0031gd2mjyba6jb7m97sqa149zjkr0vzn2s2gpb3m9nb67gqkm13"; + type = "gem"; + }; + version = "1.2.6"; + }; + multi_json = { + source = { + remotes = ["https://rubygems.org"]; + sha256 = "1rl0qy4inf1mp8mybfk56dfga0mvx97zwpmq5xmiwl5r770171nv"; + type = "gem"; + }; + version = "1.13.1"; + }; + neovim = { + dependencies = ["msgpack" "multi_json"]; + source = { + remotes = ["https://rubygems.org"]; + sha256 = "07scrdfk7pyn5jgx5m2yajdqpbdv42833vbw568qqag6xp99j3yk"; + type = "gem"; + }; + version = "0.8.0"; + }; +} diff --git a/infra/libkookie/nixpkgs/pkgs/applications/editors/neovim/system_rplugin_manifest.patch b/infra/libkookie/nixpkgs/pkgs/applications/editors/neovim/system_rplugin_manifest.patch new file mode 100644 index 000000000000..f634d3ec056a --- /dev/null +++ b/infra/libkookie/nixpkgs/pkgs/applications/editors/neovim/system_rplugin_manifest.patch @@ -0,0 +1,29 @@ +diff --git a/runtime/autoload/remote/host.vim b/runtime/autoload/remote/host.vim +index 6266b312b..965fabf1e 100644 +--- a/runtime/autoload/remote/host.vim ++++ b/runtime/autoload/remote/host.vim +@@ -71,7 +71,8 @@ function! remote#host#RegisterPlugin(host, path, specs) abort + + for plugin in plugins + if plugin.path == a:path +- throw 'Plugin "'.a:path.'" is already registered' ++ " plugin already registered ++ return + endif + endfor + +diff --git a/runtime/plugin/rplugin.vim b/runtime/plugin/rplugin.vim +index 122d8d47f..83fbf8b57 100644 +--- a/runtime/plugin/rplugin.vim ++++ b/runtime/plugin/rplugin.vim +@@ -54,6 +54,10 @@ function! s:GetManifest() abort + endfunction + + function! s:LoadRemotePlugins() abort ++ if exists('$NVIM_SYSTEM_RPLUGIN_MANIFEST') ++ let g:system_remote_plugins = fnamemodify($NVIM_SYSTEM_RPLUGIN_MANIFEST, ':p') ++ execute 'source' fnameescape(g:system_remote_plugins) ++ endif + let g:loaded_remote_plugins = s:GetManifest() + if filereadable(g:loaded_remote_plugins) + execute 'source' fnameescape(g:loaded_remote_plugins) diff --git a/infra/libkookie/nixpkgs/pkgs/applications/editors/neovim/utils.nix b/infra/libkookie/nixpkgs/pkgs/applications/editors/neovim/utils.nix new file mode 100644 index 000000000000..d992ccd3f6a4 --- /dev/null +++ b/infra/libkookie/nixpkgs/pkgs/applications/editors/neovim/utils.nix @@ -0,0 +1,160 @@ +{ lib +, vimUtils +, nodejs +, neovim-unwrapped +, bundlerEnv +, ruby +, pythonPackages +, python3Packages +, writeText +, wrapNeovimUnstable +}: +let + # returns everything needed for the caller to wrap its own neovim: + # - the generated content of the future init.vim + # - the arguments to wrap neovim with + # The caller is responsible for writing the init.vim and adding it to the wrapped + # arguments (["-u" writeText "init.vim" GENERATEDRC)]). + # This makes it possible to write the config anywhere: on a per-project basis + # .nvimrc or in $XDG_CONFIG_HOME/nvim/init.vim to avoid sideeffects. + # Indeed, note that wrapping with `-u init.vim` has sideeffects like .nvimrc wont be loaded + # anymore, $MYVIMRC wont be set etc + makeNeovimConfig = + { + withPython2 ? false + /* the function you would have passed to python.withPackages */ + , extraPython2Packages ? (_: [ ]) + , withPython3 ? true + /* the function you would have passed to python3.withPackages */ + , extraPython3Packages ? (_: [ ]) + , withNodeJs ? false + , withRuby ? true + + # same values as in vimUtils.vimrcContent + , configure ? { } + + # for forward compability, when adding new environments, haskell etc. + , ... + }@args: + let + rubyEnv = bundlerEnv { + name = "neovim-ruby-env"; + gemdir = ./ruby_provider; + postBuild = '' + ln -sf ${ruby}/bin/* $out/bin + ''; + }; + + requiredPlugins = vimUtils.requiredPlugins configure; + getDeps = attrname: map (plugin: plugin.${attrname} or (_: [ ])); + + pluginPython2Packages = getDeps "pythonDependencies" requiredPlugins; + python2Env = pythonPackages.python.withPackages (ps: + [ ps.pynvim ] + ++ (extraPython2Packages ps) + ++ (lib.concatMap (f: f ps) pluginPython2Packages)); + + pluginPython3Packages = getDeps "python3Dependencies" requiredPlugins; + python3Env = python3Packages.python.withPackages (ps: + [ ps.pynvim ] + ++ (extraPython3Packages ps) + ++ (lib.concatMap (f: f ps) pluginPython3Packages)); + + + # Mapping a boolean argument to a key that tells us whether to add or not to + # add to nvim's 'embedded rc' this: + # let g:<key>_host_prog=$out/bin/nvim-<key> + # Or this: + # let g:loaded_${prog}_provider=1 + # While the latter tells nvim that this provider is not available + hostprog_check_table = { + node = withNodeJs; + python = withPython2; + python3 = withPython3; + ruby = withRuby; + }; + ## Here we calculate all of the arguments to the 1st call of `makeWrapper` + # We start with the executable itself NOTE we call this variable "initial" + # because if configure != {} we need to call makeWrapper twice, in order to + # avoid double wrapping, see comment near finalMakeWrapperArgs + makeWrapperArgs = + let + binPath = lib.makeBinPath (lib.optionals withRuby [ rubyEnv ] ++ lib.optionals withNodeJs [ nodejs ]); + + flags = lib.concatLists (lib.mapAttrsToList ( + prog: withProg: [ + "--cmd" (genProviderSettings prog withProg) + ] + ) + hostprog_check_table); + in + [ + "--argv0" "$0" "--add-flags" (lib.escapeShellArgs flags) + ] ++ lib.optionals withRuby [ + "--set" "GEM_HOME" "${rubyEnv}/${rubyEnv.ruby.gemPath}" + ] ++ lib.optionals (binPath != "") [ + "--suffix" "PATH" ":" binPath + ]; + + manifestRc = vimUtils.vimrcContent (configure // { customRC = ""; }); + neovimRcContent = vimUtils.vimrcContent configure; + in + args // { + wrapperArgs = makeWrapperArgs; + inherit neovimRcContent; + inherit manifestRc; + inherit python2Env; + inherit python3Env; + inherit withNodeJs; + } // lib.optionalAttrs withRuby { + inherit rubyEnv; + }; + + genProviderSettings = prog: withProg: + if withProg then + "let g:${prog}_host_prog='${placeholder "out"}/bin/nvim-${prog}'" + else + "let g:loaded_${prog}_provider=1" + ; + + # to keep backwards compatibility + legacyWrapper = neovim: { + extraMakeWrapperArgs ? "" + , withPython ? true + /* the function you would have passed to python.withPackages */ + , extraPythonPackages ? (_: []) + /* the function you would have passed to python.withPackages */ + , withPython3 ? true, extraPython3Packages ? (_: []) + , withNodeJs ? false + , withRuby ? true + , vimAlias ? false + , viAlias ? false + , configure ? {} + }: + let + /* for compatibility with passing extraPythonPackages as a list; added 2018-07-11 */ + compatFun = funOrList: (if builtins.isList funOrList then + (_: lib.warn "passing a list as extraPythonPackages to the neovim wrapper is deprecated, pass a function as to python.withPackages instead" funOrList) + else funOrList); + + res = makeNeovimConfig { + withPython2 = withPython; + extraPythonPackages = compatFun extraPythonPackages; + inherit withPython3; + extraPython3Packages = compatFun extraPython3Packages; + inherit withNodeJs withRuby viAlias vimAlias; + inherit configure; + }; + in + wrapNeovimUnstable neovim (res // { + wrapperArgs = lib.escapeShellArgs ( + res.wrapperArgs ++ lib.optionals (configure != {}) [ + "--add-flags" "-u ${writeText "init.vim" res.neovimRcContent}" + ]) + " " + extraMakeWrapperArgs + ; + }); +in +{ + inherit makeNeovimConfig; + inherit legacyWrapper; +} diff --git a/infra/libkookie/nixpkgs/pkgs/applications/editors/neovim/wrapper.nix b/infra/libkookie/nixpkgs/pkgs/applications/editors/neovim/wrapper.nix new file mode 100644 index 000000000000..111e84e63437 --- /dev/null +++ b/infra/libkookie/nixpkgs/pkgs/applications/editors/neovim/wrapper.nix @@ -0,0 +1,120 @@ +{ stdenv, symlinkJoin, lib, makeWrapper +, vimUtils +, writeText +, bundlerEnv, ruby +, nodejs +, nodePackages +, pythonPackages +, python3Packages +}: +with stdenv.lib; + +neovim: + +let + wrapper = { + # should contain all args but the binary + wrapperArgs ? "" + , manifestRc ? null + , withPython2 ? true, python2Env ? null + , withPython3 ? true, python3Env ? null + , withNodeJs ? false + , rubyEnv ? null + , vimAlias ? false + , viAlias ? false + , ... + }: + let + + # If configure != {}, we can't generate the rplugin.vim file with e.g + # NVIM_SYSTEM_RPLUGIN_MANIFEST *and* NVIM_RPLUGIN_MANIFEST env vars set in + # the wrapper. That's why only when configure != {} (tested both here and + # when postBuild is evaluated), we call makeWrapper once to generate a + # wrapper with most arguments we need, excluding those that cause problems to + # generate rplugin.vim, but still required for the final wrapper. + finalMakeWrapperArgs = + [ "${neovim}/bin/nvim" "${placeholder "out"}/bin/nvim" ] ++ + [ "--set" "NVIM_SYSTEM_RPLUGIN_MANIFEST" "${placeholder "out"}/rplugin.vim" ]; + in + symlinkJoin { + name = "neovim-${stdenv.lib.getVersion neovim}"; + # Remove the symlinks created by symlinkJoin which we need to perform + # extra actions upon + postBuild = lib.optionalString stdenv.isLinux '' + rm $out/share/applications/nvim.desktop + substitute ${neovim}/share/applications/nvim.desktop $out/share/applications/nvim.desktop \ + --replace 'Name=Neovim' 'Name=WrappedNeovim' + '' + + optionalString withPython2 '' + makeWrapper ${python2Env}/bin/python $out/bin/nvim-python --unset PYTHONPATH + '' + + optionalString withPython3 '' + makeWrapper ${python3Env}/bin/python3 $out/bin/nvim-python3 --unset PYTHONPATH + '' + + optionalString (rubyEnv != null) '' + ln -s ${rubyEnv}/bin/neovim-ruby-host $out/bin/nvim-ruby + '' + + optionalString withNodeJs '' + ln -s ${nodePackages.neovim}/bin/neovim-node-host $out/bin/nvim-node + '' + + optionalString vimAlias '' + ln -s $out/bin/nvim $out/bin/vim + '' + + optionalString viAlias '' + ln -s $out/bin/nvim $out/bin/vi + '' + + optionalString (manifestRc != null) (let + manifestWrapperArgs = + [ "${neovim}/bin/nvim" "${placeholder "out"}/bin/nvim-wrapper" ]; + in '' + echo "Generating remote plugin manifest" + export NVIM_RPLUGIN_MANIFEST=$out/rplugin.vim + makeWrapper ${lib.escapeShellArgs manifestWrapperArgs} ${wrapperArgs} + + # Some plugins assume that the home directory is accessible for + # initializing caches, temporary files, etc. Even if the plugin isn't + # actively used, it may throw an error as soon as Neovim is launched + # (e.g., inside an autoload script), causing manifest generation to + # fail. Therefore, let's create a fake home directory before generating + # the manifest, just to satisfy the needs of these plugins. + # + # See https://github.com/Yggdroot/LeaderF/blob/v1.21/autoload/lfMru.vim#L10 + # for an example of this behavior. + export HOME="$(mktemp -d)" + # Launch neovim with a vimrc file containing only the generated plugin + # code. Pass various flags to disable temp file generation + # (swap/viminfo) and redirect errors to stderr. + # Only display the log on error since it will contain a few normally + # irrelevant messages. + if ! $out/bin/nvim-wrapper \ + -u ${writeText "manifest.vim" manifestRc} \ + -i NONE -n \ + -E -V1rplugins.log -s \ + +UpdateRemotePlugins +quit! > outfile 2>&1; then + cat outfile + echo -e "\nGenerating rplugin.vim failed!" + exit 1 + fi + rm "${placeholder "out"}/bin/nvim-wrapper" + '') + + '' + rm $out/bin/nvim + makeWrapper ${lib.escapeShellArgs finalMakeWrapperArgs} ${wrapperArgs} + ''; + + paths = [ neovim ]; + + preferLocalBuild = true; + + buildInputs = [makeWrapper]; + passthru = { unwrapped = neovim; }; + + meta = neovim.meta // { + # To prevent builds on hydra + hydraPlatforms = []; + # prefer wrapper over the package + priority = (neovim.meta.priority or 0) - 1; + }; + }; +in + lib.makeOverridable wrapper |