about summary refs log tree commit diff
path: root/nixpkgs/pkgs/applications/editors/neovim
diff options
context:
space:
mode:
Diffstat (limited to 'nixpkgs/pkgs/applications/editors/neovim')
-rw-r--r--nixpkgs/pkgs/applications/editors/neovim/default.nix18
-rw-r--r--nixpkgs/pkgs/applications/editors/neovim/gnvim/default.nix8
-rw-r--r--nixpkgs/pkgs/applications/editors/neovim/qt.nix1
-rw-r--r--nixpkgs/pkgs/applications/editors/neovim/wrapper.nix118
4 files changed, 101 insertions, 44 deletions
diff --git a/nixpkgs/pkgs/applications/editors/neovim/default.nix b/nixpkgs/pkgs/applications/editors/neovim/default.nix
index 0d54817c5340..b546aae790a7 100644
--- a/nixpkgs/pkgs/applications/editors/neovim/default.nix
+++ b/nixpkgs/pkgs/applications/editors/neovim/default.nix
@@ -20,16 +20,24 @@ let
     ));
 
   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.3";
+    version = "0.4.4";
 
     src = fetchFromGitHub {
       owner = "neovim";
       repo = "neovim";
       rev = "v${version}";
-      sha256 = "03p7pic7hw9yxxv7fbgls1f42apx3lik2k6mpaz1a109ngyc5kaj";
+      sha256 = "11zyj6jvkwas3n6w1ckj3pk6jf81z1g7ngg4smmwm7c27y2a6f2m";
     };
 
     patches = [
@@ -47,7 +55,7 @@ in
       libtermkey
       libuv
       libvterm-neovim
-      lua.pkgs.luv.libluv
+      luv.libluv
       msgpack
       ncurses
       neovimLuaEnv
@@ -88,10 +96,8 @@ in
     cmakeFlags = [
       "-DGPERF_PRG=${gperf}/bin/gperf"
       "-DLUA_PRG=${neovimLuaEnv.interpreter}"
+      "-DLIBLUV_LIBRARY=${luvpath}"
     ]
-    # FIXME: this is verry messy and strange.
-    ++ optional (!stdenv.isDarwin) "-DLIBLUV_LIBRARY=${lua.pkgs.luv}/lib/lua/${lua.luaversion}/luv.so"
-    ++ optional (stdenv.isDarwin) "-DLIBLUV_LIBRARY=${lua.pkgs.luv.libluv}/lib/lua/${lua.luaversion}/libluv.dylib"
     ++ optional doCheck "-DBUSTED_PRG=${neovimLuaEnv}/bin/busted"
     ++ optional (!lua.pkgs.isLuaJIT) "-DPREFER_LUA=ON"
     ;
diff --git a/nixpkgs/pkgs/applications/editors/neovim/gnvim/default.nix b/nixpkgs/pkgs/applications/editors/neovim/gnvim/default.nix
index 3693ff322338..e6166dd14b19 100644
--- a/nixpkgs/pkgs/applications/editors/neovim/gnvim/default.nix
+++ b/nixpkgs/pkgs/applications/editors/neovim/gnvim/default.nix
@@ -2,16 +2,16 @@
 
 rustPlatform.buildRustPackage rec {
   pname = "gnvim-unwrapped";
-  version = "0.1.5";
+  version = "0.1.6";
 
   src = fetchFromGitHub {
     owner = "vhakulinen";
     repo = "gnvim";
-    rev = version;
-    sha256 = "11gb59lhc1sp5dxj2fdm6072f4nxxay0war3kmchdwsk41nvxlrh";
+    rev = "v${version}";
+    sha256 = "1cc3yk04v9icdjr5cn58mqc3ba1wqmlzhf9ly7biy9m8yk30w9y0";
   };
 
-  cargoSha256 = "0ay7hx5bzchp772ywgxzia12c44kbyarrshl689cmqh59wphsrx5";
+  cargoSha256 = "1fyn8nsabzrfl9ykf2gk2p8if0yjp6k0ybrmp0pw67pbwaxpb9ym";
 
   buildInputs = [ gtk webkitgtk ];
 
diff --git a/nixpkgs/pkgs/applications/editors/neovim/qt.nix b/nixpkgs/pkgs/applications/editors/neovim/qt.nix
index 8fe93d37c7e8..b04c575dded7 100644
--- a/nixpkgs/pkgs/applications/editors/neovim/qt.nix
+++ b/nixpkgs/pkgs/applications/editors/neovim/qt.nix
@@ -38,6 +38,7 @@ let
 
     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;
diff --git a/nixpkgs/pkgs/applications/editors/neovim/wrapper.nix b/nixpkgs/pkgs/applications/editors/neovim/wrapper.nix
index c7d5f7649783..e3c03c92e58c 100644
--- a/nixpkgs/pkgs/applications/editors/neovim/wrapper.nix
+++ b/nixpkgs/pkgs/applications/editors/neovim/wrapper.nix
@@ -1,4 +1,4 @@
-{ stdenv, lib, makeWrapper
+{ stdenv, symlinkJoin, lib, makeWrapper
 , vimUtils
 , bundlerEnv, ruby
 , nodejs
@@ -55,44 +55,98 @@ let
 
   binPath = makeBinPath (optionals withRuby [rubyEnv] ++ optionals withNodeJs [nodejs]);
 
+  # 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 later tells nvim that this provider is not available
+  #
+  hostprog_check_table = {
+    node = withNodeJs;
+    python = withPython;
+    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
+  initialMakeWrapperArgs =
+    let
+      flags = lib.concatLists (lib.mapAttrsToList (
+        prog:
+        withProg:
+        [
+          "--cmd"
+          (if withProg then
+            "let g:${prog}_host_prog='${placeholder "out"}/bin/nvim-${prog}'"
+          else
+            "let g:loaded_${prog}_provider=1"
+            )
+        ]
+      ) hostprog_check_table);
+    in [
+      "${neovim}/bin/nvim" "${placeholder "out"}/bin/nvim"
+      "--argv0" "$0"
+      "--add-flags" (lib.escapeShellArgs flags)
+    ] ++ lib.optionals withRuby [
+      "--set" "GEM_HOME" "${rubyEnv}/${rubyEnv.ruby.gemPath}"
+    ] ++ lib.optionals (binPath != "") [
+      "--suffix" "PATH" ":" binPath
+    ];
+  # 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 = initialMakeWrapperArgs
+    # this relies on a patched neovim, see
+    # https://github.com/neovim/neovim/issues/9413
+    ++ lib.optionals (configure != {}) [
+      "--set" "NVIM_SYSTEM_RPLUGIN_MANIFEST" "${placeholder "out"}/rplugin.vim"
+      "--add-flags" "-u ${vimUtils.vimrcFile configure}"
+    ]
+  ;
   in
-  stdenv.mkDerivation {
+  symlinkJoin {
       name = "neovim-${stdenv.lib.getVersion neovim}";
-      buildCommand = let bin="${neovim}/bin/nvim"; in ''
-        if [ ! -x "${bin}" ]
-        then
-            echo "cannot find executable file \`${bin}'"
-            exit 1
-        fi
-
-        makeWrapper "$(readlink -v --canonicalize-existing "${bin}")" \
-          "$out/bin/nvim" --add-flags " \
-        --cmd \"${if withNodeJs then "let g:node_host_prog='${nodePackages.neovim}/bin/neovim-node-host'" else "let g:loaded_node_provider=1"}\" \
-        --cmd \"${if withPython then "let g:python_host_prog='$out/bin/nvim-python'" else "let g:loaded_python_provider = 1"}\" \
-        --cmd \"${if withPython3 then "let g:python3_host_prog='$out/bin/nvim-python3'" else "let g:loaded_python3_provider = 1"}\" \
-        --cmd \"${if withRuby then "let g:ruby_host_prog='$out/bin/nvim-ruby'" else "let g:loaded_ruby_provider=1"}\" " \
-        --suffix PATH : ${binPath} \
-        ${optionalString withRuby '' --set GEM_HOME ${rubyEnv}/${rubyEnv.ruby.gemPath}'' }
+      # Remove the symlinks created by symlinkJoin which we need to perform
+      # extra actions upon
+      postBuild = ''
+        rm $out/bin/nvim
+        makeWrapper ${lib.escapeShellArgs initialMakeWrapperArgs} ${extraMakeWrapperArgs}
       ''
-      + optionalString (!stdenv.isDarwin) ''
-        # copy icon and patch the original neovim.desktop file
-        mkdir -p $out/share/{applications,pixmaps}
-        ln -s ${neovim}/share/pixmaps/nvim.png $out/share/pixmaps/nvim.png
+      + lib.optionalString stdenv.isLinux ''
+        rm $out/share/applications/nvim.desktop
         substitute ${neovim}/share/applications/nvim.desktop $out/share/applications/nvim.desktop \
           --replace 'TryExec=nvim' "TryExec=$out/bin/nvim" \
           --replace 'Name=Neovim' 'Name=WrappedNeovim'
       ''
       + optionalString withPython ''
         makeWrapper ${pythonEnv}/bin/python $out/bin/nvim-python --unset PYTHONPATH
-      '' + optionalString withPython3 ''
+      ''
+      + optionalString withPython3 ''
         makeWrapper ${python3Env}/bin/python3 $out/bin/nvim-python3 --unset PYTHONPATH
-      '' + optionalString withRuby ''
+      ''
+      + optionalString withRuby ''
         ln -s ${rubyEnv}/bin/neovim-ruby-host $out/bin/nvim-ruby
-      '' + optionalString vimAlias ''
+      ''
+      + 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 ''
+      ''
+      + optionalString viAlias ''
         ln -s $out/bin/nvim $out/bin/vi
-      '' + optionalString (configure != {}) ''
+      ''
+      + optionalString (configure != {}) ''
         echo "Generating remote plugin manifest"
         export NVIM_RPLUGIN_MANIFEST=$out/rplugin.vim
         # Some plugins assume that the home directory is accessible for
@@ -119,22 +173,18 @@ let
           echo -e "\nGenerating rplugin.vim failed!"
           exit 1
         fi
-        unset NVIM_RPLUGIN_MANIFEST
-
-        # this relies on a patched neovim, see
-        # https://github.com/neovim/neovim/issues/9413
-        wrapProgram $out/bin/nvim \
-          --set NVIM_SYSTEM_RPLUGIN_MANIFEST $out/rplugin.vim \
-          --add-flags "-u ${vimUtils.vimrcFile configure}" ${extraMakeWrapperArgs}
+        makeWrapper ${lib.escapeShellArgs finalMakeWrapperArgs} ${extraMakeWrapperArgs}
       '';
 
+    paths = [ neovim ];
+
     preferLocalBuild = true;
 
     buildInputs = [makeWrapper];
     passthru = { unwrapped = neovim; };
 
     meta = neovim.meta // {
-      description = neovim.meta.description;
+      # To prevent builds on hydra
       hydraPlatforms = [];
       # prefer wrapper over the package
       priority = (neovim.meta.priority or 0) - 1;