@@ -1,16 +1,13 @@
1−{ stdenv, lib, fetchgit, cmake, llvmPackages, boost, python2Packages
1+{ stdenv, lib, fetchgit, cmake, llvmPackages, boost, python
22, gocode ? null
33, godef ? null
44, rustracerd ? null
5+, Cocoa ? null
56}:
67
7−let
8− inherit (python2Packages) python mkPythonDerivation waitress frozendict bottle future argparse requests;
9− pathFixup = "import os; os.environ['PATH'] = ('{0}:{1}' if os.getenv('PATH', '') != '' else '{1}').format('$program_PATH', os.getenv('PATH', ''))";
10−in mkPythonDerivation rec {
8+stdenv.mkDerivation rec {
119 name = "ycmd-${version}";
1210 version = "2017-02-03";
13− namePrefix = "";
1411
1512 src = fetchgit {
1613 url = "git://github.com/Valloric/ycmd.git";
@@ -18,30 +15,32 @@ in mkPythonDerivation rec {
1815 sha256 = "0rzxgqqqmmrv9r4k2ji074iprhw6sb0jkvh84wvi45yfyphsh0xi";
1916 };
2017
21− buildInputs = [ cmake boost ];
22−
23− propagatedBuildInputs = [ waitress frozendict bottle future argparse requests ];
18+ buildInputs = [ cmake boost ] ++ stdenv.lib.optional stdenv.isDarwin Cocoa;
2419
2520 buildPhase = ''
2621 export EXTRA_CMAKE_ARGS=-DPATH_TO_LLVM_ROOT=${llvmPackages.clang-unwrapped}
2722 ${python.interpreter} build.py --clang-completer --system-boost
2823 '';
2924
25+ patches = [ ./2-ycm-cmake.patch ];
26+
3027 configurePhase = ":";
3128
3229 # remove the tests
3330 #
34− # make __main__.py executable so mkPythonDerivation's postFixup modifies the
35− # executable (e.g. fixup PYTHONPATH)
31+ # make __main__.py executable and add shebang
3632 #
37− # add a shebang (will be rewritten by postFixup)
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
3837 #
3938 # symlink completion backends where ycmd expects them
4039 installPhase = ''
4140 rm -rf ycmd/tests
4241
4342 chmod +x ycmd/__main__.py
44− sed -i "1i #!/usr/bin/env python\
43+ sed -i "1i #!${python.interpreter}\
4544 " ycmd/__main__.py
4645
4746 mkdir -p $out/lib/ycmd
@@ -51,7 +50,12 @@ in mkPythonDerivation rec {
5150 ln -s $out/lib/ycmd/ycmd/__main__.py $out/bin/ycmd
5251
5352 mkdir -p $out/lib/ycmd/third_party/{gocode,godef,racerd/target/release}
54− cp -r third_party/JediHTTP/ $out/lib/ycmd/third_party
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+
5559 '' + lib.optionalString (gocode != null) ''
5660 ln -s ${gocode}/bin/gocode $out/lib/ycmd/third_party/gocode
5761 '' + lib.optionalString (godef != null) ''
@@ -60,16 +64,9 @@ in mkPythonDerivation rec {
6064 ln -s ${rustracerd}/bin/racerd $out/lib/ycmd/third_party/racerd/target/release
6165 '';
6266
63− # mkPythonDerivation will attempt to create a wrapper script (written in bash)
64− # but we don't want the indirection as several editor plugins want to invoke
65− # ycmd as `python path/to/ycmd`, which will obviously fail in that case -
66− # so we move the original file back over
67− #
68− # also fixup the argv[0] and replace __file__ with the corresponding path so
67+ # fixup the argv[0] and replace __file__ with the corresponding path so
6968 # python won't be thrown off by argv[0]
7069 postFixup = ''
71− mv $out/lib/ycmd/ycmd/{.__main__.py-wrapped,__main__.py}
72−
7370 substituteInPlace $out/lib/ycmd/ycmd/__main__.py \
7471 --replace $out/lib/ycmd/ycmd/__main__.py \
7572 $out/bin/ycmd \
@@ -81,7 +78,7 @@ in mkPythonDerivation rec {
8178 description = "A code-completion and comprehension server";
8279 homepage = https://github.com/Valloric/ycmd;
8380 license = licenses.gpl3;
84− maintainers = with maintainers; [ rasendubi ];
81+ maintainers = with maintainers; [ rasendubi cstrahan ];
8582 platforms = platforms.all;
8683 };
8784}