@@ -1,40 +1,84 @@
1−{ stdenv, fetchgit, cmake, llvmPackages, boost, python2Packages
1+{ stdenv, lib, fetchgit, cmake, llvmPackages, boost, python
2+, gocode ? null
3+, godef ? null
4+, rustracerd ? null
5+, Cocoa ? null
26}:
37
4−let
5− inherit (python2Packages) python mkPythonDerivation waitress frozendict bottle;
6−in mkPythonDerivation rec {
7− name = "ycmd-2016-01-12";
8− namePrefix = "";
8+stdenv.mkDerivation rec {
9+ name = "ycmd-${version}";
10+ version = "2017-02-03";
911
1012 src = fetchgit {
1113 url = "git://github.com/Valloric/ycmd.git";
12− rev = "f982f6251c5ff85e3abe6e862aad8bcd19e85ece";
13− sha256 = "1g0hivv3wla7z5dgnkcn3ny38p089pjfj36nx6k29zmprgmjinyr";
14+ rev = "ec7a154f8fe50c071ecd0ac6841de8a50ce92f5d";
15+ sha256 = "0rzxgqqqmmrv9r4k2ji074iprhw6sb0jkvh84wvi45yfyphsh0xi";
1416 };
1517
16− buildInputs = [ cmake boost ];
17−
18− propagatedBuildInputs = [ waitress frozendict bottle ];
18+ buildInputs = [ cmake boost ] ++ stdenv.lib.optional stdenv.isDarwin Cocoa;
1919
2020 buildPhase = ''
2121 export EXTRA_CMAKE_ARGS=-DPATH_TO_LLVM_ROOT=${llvmPackages.clang-unwrapped}
2222 ${python.interpreter} build.py --clang-completer --system-boost
2323 '';
2424
25+ patches = [ ./2-ycm-cmake.patch ];
26+
2527 configurePhase = ":";
2628
29+ # remove the tests
30+ #
31+ # make __main__.py executable and add shebang
32+ #
33+ # copy over third-party libs
34+ # note: if we switch to using our packaged libs, we'll need to symlink them
35+ # into the same spots, as YouCompleteMe (the vim plugin) expects those paths
36+ # to be available
37+ #
38+ # symlink completion backends where ycmd expects them
2739 installPhase = ''
28− mkdir -p $out/lib/ycmd/third_party $out/bin
29− cp -r ycmd/ CORE_VERSION libclang.so.* ycm_client_support.so ycm_core.so $out/lib/ycmd/
40+ rm -rf ycmd/tests
41+
42+ chmod +x ycmd/__main__.py
43+ sed -i "1i #!${python.interpreter}\
44+ " ycmd/__main__.py
45+
46+ mkdir -p $out/lib/ycmd
47+ cp -r ycmd/ CORE_VERSION libclang.so.* ycm_core.so $out/lib/ycmd/
48+
49+ mkdir -p $out/bin
3050 ln -s $out/lib/ycmd/ycmd/__main__.py $out/bin/ycmd
51+
52+ mkdir -p $out/lib/ycmd/third_party/{gocode,godef,racerd/target/release}
53+
54+ cp -r third_party/JediHTTP $out/lib/ycmd/third_party
55+ for p in waitress frozendict bottle python-future argparse requests; do
56+ cp -r third_party/$p $out/lib/ycmd/third_party
57+ done
58+
59+ '' + lib.optionalString (gocode != null) ''
60+ ln -s ${gocode}/bin/gocode $out/lib/ycmd/third_party/gocode
61+ '' + lib.optionalString (godef != null) ''
62+ ln -s ${godef}/bin/godef $out/lib/ycmd/third_party/godef
63+ '' + lib.optionalString (rustracerd != null) ''
64+ ln -s ${rustracerd}/bin/racerd $out/lib/ycmd/third_party/racerd/target/release
65+ '';
66+
67+ # fixup the argv[0] and replace __file__ with the corresponding path so
68+ # python won't be thrown off by argv[0]
69+ postFixup = ''
70+ substituteInPlace $out/lib/ycmd/ycmd/__main__.py \
71+ --replace $out/lib/ycmd/ycmd/__main__.py \
72+ $out/bin/ycmd \
73+ --replace __file__ \
74+ "'$out/lib/ycmd/ycmd/__main__.py'"
3175 '';
3276
3377 meta = with stdenv.lib; {
3478 description = "A code-completion and comprehension server";
3579 homepage = https://github.com/Valloric/ycmd;
3680 license = licenses.gpl3;
37− maintainers = with maintainers; [ rasendubi ];
81+ maintainers = with maintainers; [ rasendubi cstrahan ];
3882 platforms = platforms.all;
3983 };
4084}