2022-03-09 10:27:03 +01:00
|
|
|
{ stdenv, lib, fetchFromGitHub, cmake, llvmPackages, boost, python
|
2021-10-26 13:35:17 +02:00
|
|
|
, withGocode ? true, gocode
|
|
|
|
, withGodef ? true, godef
|
|
|
|
, withGotools? true, gotools
|
|
|
|
, withTypescript ? true, nodePackages
|
|
|
|
, fixDarwinDylibNames, Cocoa
|
2016-01-05 15:28:15 +01:00
|
|
|
}:
|
|
|
|
|
2019-08-13 23:52:01 +02:00
|
|
|
stdenv.mkDerivation {
|
2019-08-15 14:41:18 +02:00
|
|
|
pname = "ycmd";
|
2021-10-26 13:35:17 +02:00
|
|
|
version = "unstable-2020-02-22";
|
2020-02-25 16:28:26 +01:00
|
|
|
disabled = !python.isPy3k;
|
2016-01-05 15:28:15 +01:00
|
|
|
|
2021-10-26 13:35:17 +02:00
|
|
|
# required for third_party directory creation
|
2022-03-09 10:27:03 +01:00
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "Valloric";
|
|
|
|
repo = "ycmd";
|
2020-02-25 16:28:26 +01:00
|
|
|
rev = "9a6b86e3a156066335b678c328f226229746bae5";
|
2022-03-09 10:27:03 +01:00
|
|
|
sha256 = "sha256-xzLELjp4DsG6mkzaFqpuquSa0uoaZWrYLrKr/mzrqrA=";
|
|
|
|
fetchSubmodules = true;
|
2016-01-05 15:28:15 +01:00
|
|
|
};
|
|
|
|
|
2020-10-26 08:17:14 +01:00
|
|
|
nativeBuildInputs = [ cmake ]
|
2021-01-23 13:26:19 +01:00
|
|
|
++ lib.optional stdenv.hostPlatform.isDarwin fixDarwinDylibNames;
|
2018-01-16 22:55:36 +01:00
|
|
|
buildInputs = [ boost llvmPackages.libclang ]
|
2021-10-26 13:35:17 +02:00
|
|
|
++ lib.optional stdenv.isDarwin Cocoa;
|
2016-01-05 15:28:15 +01:00
|
|
|
|
|
|
|
buildPhase = ''
|
2016-08-18 00:35:30 +02:00
|
|
|
export EXTRA_CMAKE_ARGS=-DPATH_TO_LLVM_ROOT=${llvmPackages.clang-unwrapped}
|
2018-01-16 22:55:36 +01:00
|
|
|
${python.interpreter} build.py --system-libclang --clang-completer --system-boost
|
2016-01-05 15:28:15 +01:00
|
|
|
'';
|
|
|
|
|
2019-06-19 17:36:06 +02:00
|
|
|
dontConfigure = true;
|
2016-01-05 15:28:15 +01:00
|
|
|
|
2017-02-06 08:43:58 +01:00
|
|
|
# remove the tests
|
|
|
|
#
|
2017-02-10 05:39:16 +01:00
|
|
|
# make __main__.py executable and add shebang
|
2017-02-06 08:43:58 +01:00
|
|
|
#
|
2017-02-10 05:39:16 +01:00
|
|
|
# copy over third-party libs
|
|
|
|
# note: if we switch to using our packaged libs, we'll need to symlink them
|
|
|
|
# into the same spots, as YouCompleteMe (the vim plugin) expects those paths
|
|
|
|
# to be available
|
2017-02-06 08:43:58 +01:00
|
|
|
#
|
|
|
|
# symlink completion backends where ycmd expects them
|
2016-11-09 13:59:28 +01:00
|
|
|
installPhase = ''
|
2017-02-06 08:43:58 +01:00
|
|
|
rm -rf ycmd/tests
|
|
|
|
|
|
|
|
chmod +x ycmd/__main__.py
|
2017-02-10 05:39:16 +01:00
|
|
|
sed -i "1i #!${python.interpreter}\
|
2017-02-06 08:43:58 +01:00
|
|
|
" ycmd/__main__.py
|
|
|
|
|
|
|
|
mkdir -p $out/lib/ycmd
|
2017-04-30 17:27:00 +02:00
|
|
|
cp -r ycmd/ CORE_VERSION libclang.so.* libclang.dylib* ycm_core.so $out/lib/ycmd/
|
2017-02-06 08:43:58 +01:00
|
|
|
|
|
|
|
mkdir -p $out/bin
|
2016-01-05 15:28:15 +01:00
|
|
|
ln -s $out/lib/ycmd/ycmd/__main__.py $out/bin/ycmd
|
2017-02-06 08:43:58 +01:00
|
|
|
|
2019-09-20 15:23:09 +02:00
|
|
|
# Copy everything: the structure of third_party has been known to change.
|
|
|
|
# When linking our own libraries below, do so with '-f'
|
|
|
|
# to clobber anything we may have copied here.
|
2019-09-20 20:22:09 +02:00
|
|
|
mkdir -p $out/lib/ycmd/third_party
|
2019-09-20 15:23:09 +02:00
|
|
|
cp -r third_party/* $out/lib/ycmd/third_party/
|
2017-02-10 05:39:16 +01:00
|
|
|
|
2021-10-26 13:35:17 +02:00
|
|
|
'' + lib.optionalString withGocode ''
|
2019-09-20 20:22:09 +02:00
|
|
|
TARGET=$out/lib/ycmd/third_party/gocode
|
|
|
|
mkdir -p $TARGET
|
|
|
|
ln -sf ${gocode}/bin/gocode $TARGET
|
2021-10-26 13:35:17 +02:00
|
|
|
'' + lib.optionalString withGodef ''
|
2019-09-20 20:22:09 +02:00
|
|
|
TARGET=$out/lib/ycmd/third_party/godef
|
|
|
|
mkdir -p $TARGET
|
|
|
|
ln -sf ${godef}/bin/godef $TARGET
|
2021-10-26 13:35:17 +02:00
|
|
|
'' + lib.optionalString withGotools ''
|
2019-09-20 20:22:09 +02:00
|
|
|
TARGET=$out/lib/ycmd/third_party/go/src/golang.org/x/tools/cmd/gopls
|
|
|
|
mkdir -p $TARGET
|
|
|
|
ln -sf ${gotools}/bin/gopls $TARGET
|
2021-10-26 13:35:17 +02:00
|
|
|
'' + lib.optionalString withTypescript ''
|
2020-04-24 21:02:31 +02:00
|
|
|
TARGET=$out/lib/ycmd/third_party/tsserver
|
|
|
|
ln -sf ${nodePackages.typescript} $TARGET
|
2017-02-06 08:43:58 +01:00
|
|
|
'';
|
|
|
|
|
2017-02-10 05:39:16 +01:00
|
|
|
# fixup the argv[0] and replace __file__ with the corresponding path so
|
2017-02-06 08:43:58 +01:00
|
|
|
# python won't be thrown off by argv[0]
|
|
|
|
postFixup = ''
|
|
|
|
substituteInPlace $out/lib/ycmd/ycmd/__main__.py \
|
2021-10-26 13:35:17 +02:00
|
|
|
--replace $out/lib/ycmd/ycmd/__main__.py $out/bin/ycmd \
|
|
|
|
--replace __file__ "'$out/lib/ycmd/ycmd/__main__.py'"
|
2016-01-05 15:28:15 +01:00
|
|
|
'';
|
|
|
|
|
2021-01-23 13:26:19 +01:00
|
|
|
meta = with lib; {
|
2016-01-05 15:28:15 +01:00
|
|
|
description = "A code-completion and comprehension server";
|
2020-04-01 03:11:51 +02:00
|
|
|
homepage = "https://github.com/Valloric/ycmd";
|
2016-07-08 01:40:33 +02:00
|
|
|
license = licenses.gpl3;
|
2017-04-30 17:27:00 +02:00
|
|
|
maintainers = with maintainers; [ rasendubi cstrahan lnl7 ];
|
2016-07-08 01:40:33 +02:00
|
|
|
platforms = platforms.all;
|
2016-01-05 15:28:15 +01:00
|
|
|
};
|
|
|
|
}
|