nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{ stdenv, lib, fetchgit, cmake, llvmPackages, boost, python
2, gocode ? null
3, godef ? null
4, rustracerd ? null
5, fixDarwinDylibNames, Cocoa ? null
6}:
7
8stdenv.mkDerivation rec {
9 name = "ycmd-${version}";
10 version = "2018-09-20";
11
12 src = fetchgit {
13 url = "https://github.com/Valloric/ycmd.git";
14 rev = "bf658fd78722c517674c0aaf2381e199bca8f163";
15 sha256 = "1lwa8xr76vapfpncvp81cn3m9219yw14fl7fzk5gnly60zkphbbl";
16 };
17
18 nativeBuildInputs = [ cmake ];
19 buildInputs = [ boost llvmPackages.libclang ]
20 ++ stdenv.lib.optional stdenv.isDarwin [ fixDarwinDylibNames Cocoa ];
21
22 buildPhase = ''
23 export EXTRA_CMAKE_ARGS=-DPATH_TO_LLVM_ROOT=${llvmPackages.clang-unwrapped}
24 ${python.interpreter} build.py --system-libclang --clang-completer --system-boost
25 '';
26
27 configurePhase = ":";
28
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
39 installPhase = ''
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.* libclang.dylib* ycm_core.so $out/lib/ycmd/
48
49 mkdir -p $out/bin
50 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 for p in jedi waitress frozendict bottle parso python-future requests; do
55 cp -r third_party/$p $out/lib/ycmd/third_party
56 done
57
58 '' + lib.optionalString (gocode != null) ''
59 ln -s ${gocode}/bin/gocode $out/lib/ycmd/third_party/gocode
60 '' + lib.optionalString (godef != null) ''
61 ln -s ${godef}/bin/godef $out/lib/ycmd/third_party/godef
62 '' + lib.optionalString (rustracerd != null) ''
63 ln -s ${rustracerd}/bin/racerd $out/lib/ycmd/third_party/racerd/target/release
64 '';
65
66 # fixup the argv[0] and replace __file__ with the corresponding path so
67 # python won't be thrown off by argv[0]
68 postFixup = ''
69 substituteInPlace $out/lib/ycmd/ycmd/__main__.py \
70 --replace $out/lib/ycmd/ycmd/__main__.py \
71 $out/bin/ycmd \
72 --replace __file__ \
73 "'$out/lib/ycmd/ycmd/__main__.py'"
74 '';
75
76 meta = with stdenv.lib; {
77 description = "A code-completion and comprehension server";
78 homepage = https://github.com/Valloric/ycmd;
79 license = licenses.gpl3;
80 maintainers = with maintainers; [ rasendubi cstrahan lnl7 ];
81 platforms = platforms.all;
82 };
83}