2023-07-15 17:15:38 +00:00
|
|
|
{ lib, stdenv, fetchFromGitHub, cmake, gettext, msgpack-c, libtermkey, libiconv
|
2021-02-05 17:12:51 +00:00
|
|
|
, libuv, lua, ncurses, pkg-config
|
2021-12-06 16:07:01 +00:00
|
|
|
, unibilium, gperf
|
2020-04-24 23:36:52 +00:00
|
|
|
, libvterm-neovim
|
2021-07-03 03:11:41 +00:00
|
|
|
, tree-sitter
|
2023-05-24 13:37:59 +00:00
|
|
|
, fetchurl
|
2023-08-04 22:07:22 +00:00
|
|
|
, buildPackages
|
2023-05-24 13:37:59 +00:00
|
|
|
, treesitter-parsers ? import ./treesitter-parsers.nix { inherit fetchurl; }
|
2022-06-16 17:23:12 +00:00
|
|
|
, CoreServices
|
2023-10-09 19:29:22 +00:00
|
|
|
, fixDarwinDylibNames
|
2020-04-24 23:36:52 +00:00
|
|
|
, glibcLocales ? null, procps ? null
|
|
|
|
|
2022-04-03 18:54:34 +00:00
|
|
|
# now defaults to false because some tests can be flaky (clipboard etc), see
|
|
|
|
# also: https://github.com/neovim/neovim/issues/16233
|
2020-04-24 23:36:52 +00:00
|
|
|
, doCheck ? false
|
2021-05-03 20:48:10 +00:00
|
|
|
, nodejs ? null, fish ? null, python3 ? null
|
2020-04-24 23:36:52 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
2023-10-09 19:29:22 +00:00
|
|
|
nvim-lpeg-dylib = luapkgs: if stdenv.isDarwin
|
|
|
|
then (luapkgs.lpeg.overrideAttrs (oa: {
|
|
|
|
preConfigure = ''
|
|
|
|
# neovim wants clang .dylib
|
|
|
|
sed -i makefile -e "s/CC = gcc/CC = clang/"
|
|
|
|
sed -i makefile -e "s/-bundle/-dynamiclib/"
|
|
|
|
'';
|
|
|
|
preBuild = ''
|
|
|
|
# there seems to be implicit calls to Makefile from luarocks, we need to
|
|
|
|
# add a stage to build our dylib
|
|
|
|
make macosx
|
|
|
|
mkdir -p $out/lib
|
|
|
|
mv lpeg.so $out/lib/lpeg.dylib
|
|
|
|
'';
|
|
|
|
nativeBuildInputs =
|
|
|
|
oa.nativeBuildInputs
|
|
|
|
++ (
|
|
|
|
lib.optional stdenv.isDarwin fixDarwinDylibNames
|
|
|
|
);
|
|
|
|
}))
|
|
|
|
else luapkgs.lpeg;
|
2023-08-04 22:07:22 +00:00
|
|
|
requiredLuaPkgs = ps: (with ps; [
|
2023-10-09 19:29:22 +00:00
|
|
|
(nvim-lpeg-dylib ps)
|
2023-08-04 22:07:22 +00:00
|
|
|
luabitop
|
|
|
|
mpack
|
|
|
|
] ++ lib.optionals doCheck [
|
|
|
|
luv
|
|
|
|
coxpcall
|
|
|
|
busted
|
|
|
|
luafilesystem
|
|
|
|
penlight
|
|
|
|
inspect
|
|
|
|
]
|
|
|
|
);
|
|
|
|
neovimLuaEnv = lua.withPackages requiredLuaPkgs;
|
|
|
|
neovimLuaEnvOnBuild = lua.luaOnBuild.withPackages requiredLuaPkgs;
|
2023-01-11 07:51:40 +00:00
|
|
|
codegenLua =
|
2023-08-04 22:07:22 +00:00
|
|
|
if lua.luaOnBuild.pkgs.isLuaJIT
|
2023-01-11 07:51:40 +00:00
|
|
|
then
|
|
|
|
let deterministicLuajit =
|
2023-08-04 22:07:22 +00:00
|
|
|
lua.luaOnBuild.override {
|
2023-01-11 07:51:40 +00:00
|
|
|
deterministicStringIds = true;
|
|
|
|
self = deterministicLuajit;
|
|
|
|
};
|
2023-10-09 19:29:22 +00:00
|
|
|
in deterministicLuajit.withPackages(ps: [ ps.mpack (nvim-lpeg-dylib ps) ])
|
2023-08-04 22:07:22 +00:00
|
|
|
else lua.luaOnBuild;
|
2020-06-18 07:06:33 +00:00
|
|
|
|
2021-05-03 20:48:10 +00:00
|
|
|
pyEnv = python3.withPackages(ps: with ps; [ pynvim msgpack ]);
|
2023-10-09 19:29:22 +00:00
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
in
|
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
pname = "neovim-unwrapped";
|
2024-01-02 11:29:13 +00:00
|
|
|
version = "0.9.5";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "neovim";
|
|
|
|
repo = "neovim";
|
|
|
|
rev = "v${version}";
|
2024-01-02 11:29:13 +00:00
|
|
|
hash = "sha256-CcaBqA0yFCffNPmXOJTo8c9v1jrEBiqAl8CG5Dj5YxE=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
2021-09-18 10:52:07 +00:00
|
|
|
inherit lua;
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
buildInputs = [
|
|
|
|
gperf
|
|
|
|
libtermkey
|
|
|
|
libuv
|
|
|
|
libvterm-neovim
|
2022-04-03 18:54:34 +00:00
|
|
|
# This is actually a c library, hence it's not included in neovimLuaEnv,
|
|
|
|
# see:
|
|
|
|
# https://github.com/luarocks/luarocks/issues/1402#issuecomment-1080616570
|
|
|
|
# and it's definition at: pkgs/development/lua-modules/overrides.nix
|
|
|
|
lua.pkgs.libluv
|
2023-07-15 17:15:38 +00:00
|
|
|
msgpack-c
|
2020-04-24 23:36:52 +00:00
|
|
|
ncurses
|
|
|
|
neovimLuaEnv
|
2021-07-03 03:11:41 +00:00
|
|
|
tree-sitter
|
2020-04-24 23:36:52 +00:00
|
|
|
unibilium
|
2022-12-17 10:02:37 +00:00
|
|
|
] ++ lib.optionals stdenv.isDarwin [ libiconv CoreServices ]
|
|
|
|
++ lib.optionals doCheck [ glibcLocales procps ]
|
2020-04-24 23:36:52 +00:00
|
|
|
;
|
|
|
|
|
|
|
|
inherit doCheck;
|
|
|
|
|
|
|
|
# to be exhaustive, one could run
|
|
|
|
# make oldtests too
|
|
|
|
checkPhase = ''
|
|
|
|
make functionaltest
|
|
|
|
'';
|
|
|
|
|
|
|
|
nativeBuildInputs = [
|
|
|
|
cmake
|
|
|
|
gettext
|
2021-02-05 17:12:51 +00:00
|
|
|
pkg-config
|
2020-04-24 23:36:52 +00:00
|
|
|
];
|
|
|
|
|
2020-06-18 07:06:33 +00:00
|
|
|
# extra programs test via `make functionaltest`
|
2023-02-02 18:25:31 +00:00
|
|
|
nativeCheckInputs = [
|
2020-06-18 07:06:33 +00:00
|
|
|
fish
|
|
|
|
nodejs
|
|
|
|
pyEnv # for src/clint.py
|
|
|
|
];
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
# nvim --version output retains compilation flags and references to build tools
|
|
|
|
postPatch = ''
|
|
|
|
substituteInPlace src/nvim/version.c --replace NVIM_VERSION_CFLAGS "";
|
2023-08-04 22:07:22 +00:00
|
|
|
'' + lib.optionalString (!stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
|
|
|
|
sed -i runtime/CMakeLists.txt \
|
|
|
|
-e "s|\".*/bin/nvim|\${stdenv.hostPlatform.emulator buildPackages} &|g"
|
|
|
|
sed -i src/nvim/po/CMakeLists.txt \
|
|
|
|
-e "s|\$<TARGET_FILE:nvim|\${stdenv.hostPlatform.emulator buildPackages} &|g"
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
# check that the above patching actually works
|
2023-01-11 07:51:40 +00:00
|
|
|
disallowedReferences = [ stdenv.cc ] ++ lib.optional (lua != codegenLua) codegenLua;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
cmakeFlags = [
|
2022-04-03 18:54:34 +00:00
|
|
|
# Don't use downloaded dependencies. At the end of the configurePhase one
|
|
|
|
# can spot that cmake says this option was "not used by the project".
|
|
|
|
# That's because all dependencies were found and
|
|
|
|
# third-party/CMakeLists.txt is not read at all.
|
2021-07-03 03:11:41 +00:00
|
|
|
"-DUSE_BUNDLED=OFF"
|
2020-04-24 23:36:52 +00:00
|
|
|
]
|
2022-12-17 10:02:37 +00:00
|
|
|
++ lib.optional (!lua.pkgs.isLuaJIT) "-DPREFER_LUA=ON"
|
2020-04-24 23:36:52 +00:00
|
|
|
;
|
|
|
|
|
2023-01-11 07:51:40 +00:00
|
|
|
preConfigure = lib.optionalString lua.pkgs.isLuaJIT ''
|
|
|
|
cmakeFlagsArray+=(
|
|
|
|
"-DLUAC_PRG=${codegenLua}/bin/luajit -b -s %s -"
|
|
|
|
"-DLUA_GEN_PRG=${codegenLua}/bin/luajit"
|
2023-08-04 22:07:22 +00:00
|
|
|
"-DLUA_PRG=${neovimLuaEnvOnBuild}/bin/luajit"
|
2023-01-11 07:51:40 +00:00
|
|
|
)
|
|
|
|
'' + lib.optionalString stdenv.isDarwin ''
|
2020-04-24 23:36:52 +00:00
|
|
|
substituteInPlace src/nvim/CMakeLists.txt --replace " util" ""
|
2023-05-24 13:37:59 +00:00
|
|
|
'' + ''
|
|
|
|
mkdir -p $out/lib/nvim/parser
|
|
|
|
'' + lib.concatStrings (lib.mapAttrsToList
|
|
|
|
(language: src: ''
|
|
|
|
ln -s \
|
|
|
|
${tree-sitter.buildGrammar {
|
|
|
|
inherit language src;
|
|
|
|
version = "neovim-${version}";
|
|
|
|
}}/parser \
|
|
|
|
$out/lib/nvim/parser/${language}.so
|
|
|
|
'')
|
|
|
|
treesitter-parsers);
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
shellHook=''
|
|
|
|
export VIMRUNTIME=$PWD/runtime
|
|
|
|
'';
|
|
|
|
|
2023-05-24 13:37:59 +00:00
|
|
|
separateDebugInfo = true;
|
|
|
|
|
2022-12-17 10:02:37 +00:00
|
|
|
meta = with lib; {
|
2020-04-24 23:36:52 +00:00
|
|
|
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";
|
2021-07-14 22:03:04 +00:00
|
|
|
mainProgram = "nvim";
|
2020-04-24 23:36:52 +00:00
|
|
|
# "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 ];
|
2022-06-26 10:26:21 +00:00
|
|
|
maintainers = with maintainers; [ manveru rvolosatovs ];
|
2020-04-24 23:36:52 +00:00
|
|
|
platforms = platforms.unix;
|
|
|
|
};
|
|
|
|
}
|