nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{ stdenv, lib, fetchgit, cmake, llvmPackages, boost, python
2, gocode ? null
3, godef ? null
4, gotools ? null
5, rustracerd ? null
6, fixDarwinDylibNames, Cocoa ? null
7}:
8
9stdenv.mkDerivation {
10 pname = "ycmd";
11 version = "2019-09-19";
12
13 src = fetchgit {
14 url = "https://github.com/Valloric/ycmd.git";
15 rev = "c6d360775b0c5c82e2513dce7b625f8bf3812702";
16 sha256 = "19rxlval20gg65xc5p7q9cnzfm9zw2j0m6vxxk0vqlalcyh0rnzd";
17 };
18
19 nativeBuildInputs = [ cmake ];
20 buildInputs = [ boost llvmPackages.libclang ]
21 ++ stdenv.lib.optional stdenv.isDarwin [ fixDarwinDylibNames Cocoa ];
22
23 buildPhase = ''
24 export EXTRA_CMAKE_ARGS=-DPATH_TO_LLVM_ROOT=${llvmPackages.clang-unwrapped}
25 ${python.interpreter} build.py --system-libclang --clang-completer --system-boost
26 '';
27
28 dontConfigure = true;
29
30 # remove the tests
31 #
32 # make __main__.py executable and add shebang
33 #
34 # copy over third-party libs
35 # note: if we switch to using our packaged libs, we'll need to symlink them
36 # into the same spots, as YouCompleteMe (the vim plugin) expects those paths
37 # to be available
38 #
39 # symlink completion backends where ycmd expects them
40 installPhase = ''
41 rm -rf ycmd/tests
42
43 chmod +x ycmd/__main__.py
44 sed -i "1i #!${python.interpreter}\
45 " ycmd/__main__.py
46
47 mkdir -p $out/lib/ycmd
48 cp -r ycmd/ CORE_VERSION libclang.so.* libclang.dylib* ycm_core.so $out/lib/ycmd/
49
50 mkdir -p $out/bin
51 ln -s $out/lib/ycmd/ycmd/__main__.py $out/bin/ycmd
52
53 # Copy everything: the structure of third_party has been known to change.
54 # When linking our own libraries below, do so with '-f'
55 # to clobber anything we may have copied here.
56 mkdir -p $out/lib/ycmd/third_party
57 cp -r third_party/* $out/lib/ycmd/third_party/
58
59 '' + lib.optionalString (gocode != null) ''
60 TARGET=$out/lib/ycmd/third_party/gocode
61 mkdir -p $TARGET
62 ln -sf ${gocode}/bin/gocode $TARGET
63 '' + lib.optionalString (godef != null) ''
64 TARGET=$out/lib/ycmd/third_party/godef
65 mkdir -p $TARGET
66 ln -sf ${godef}/bin/godef $TARGET
67 '' + lib.optionalString (gotools != null) ''
68 TARGET=$out/lib/ycmd/third_party/go/src/golang.org/x/tools/cmd/gopls
69 mkdir -p $TARGET
70 ln -sf ${gotools}/bin/gopls $TARGET
71 '' + lib.optionalString (rustracerd != null) ''
72 TARGET=$out/lib/ycmd/third_party/racerd/target/release
73 mkdir -p $TARGET
74 ln -sf ${rustracerd}/bin/racerd $TARGET
75 '';
76
77 # fixup the argv[0] and replace __file__ with the corresponding path so
78 # python won't be thrown off by argv[0]
79 postFixup = ''
80 substituteInPlace $out/lib/ycmd/ycmd/__main__.py \
81 --replace $out/lib/ycmd/ycmd/__main__.py \
82 $out/bin/ycmd \
83 --replace __file__ \
84 "'$out/lib/ycmd/ycmd/__main__.py'"
85 '';
86
87 meta = with stdenv.lib; {
88 description = "A code-completion and comprehension server";
89 homepage = https://github.com/Valloric/ycmd;
90 license = licenses.gpl3;
91 maintainers = with maintainers; [ rasendubi cstrahan lnl7 ];
92 platforms = platforms.all;
93 };
94}