at 22.05-pre 94 lines 3.1 kB view raw
1{ stdenv, lib, fetchgit, cmake, llvmPackages, boost, python 2, withGocode ? true, gocode 3, withGodef ? true, godef 4, withGotools? true, gotools 5, withTypescript ? true, nodePackages 6, fixDarwinDylibNames, Cocoa 7}: 8 9stdenv.mkDerivation { 10 pname = "ycmd"; 11 version = "unstable-2020-02-22"; 12 disabled = !python.isPy3k; 13 14 # required for third_party directory creation 15 src = fetchgit { 16 url = "https://github.com/Valloric/ycmd.git"; 17 rev = "9a6b86e3a156066335b678c328f226229746bae5"; 18 sha256 = "1c5axdngxaxj5vc6lr8sxb99mr5adsm1dnjckaxc23kq78pc8cn7"; 19 }; 20 21 nativeBuildInputs = [ cmake ] 22 ++ lib.optional stdenv.hostPlatform.isDarwin fixDarwinDylibNames; 23 buildInputs = [ boost llvmPackages.libclang ] 24 ++ lib.optional stdenv.isDarwin Cocoa; 25 26 buildPhase = '' 27 export EXTRA_CMAKE_ARGS=-DPATH_TO_LLVM_ROOT=${llvmPackages.clang-unwrapped} 28 ${python.interpreter} build.py --system-libclang --clang-completer --system-boost 29 ''; 30 31 dontConfigure = true; 32 33 # remove the tests 34 # 35 # make __main__.py executable and add shebang 36 # 37 # copy over third-party libs 38 # note: if we switch to using our packaged libs, we'll need to symlink them 39 # into the same spots, as YouCompleteMe (the vim plugin) expects those paths 40 # to be available 41 # 42 # symlink completion backends where ycmd expects them 43 installPhase = '' 44 rm -rf ycmd/tests 45 46 chmod +x ycmd/__main__.py 47 sed -i "1i #!${python.interpreter}\ 48 " ycmd/__main__.py 49 50 mkdir -p $out/lib/ycmd 51 cp -r ycmd/ CORE_VERSION libclang.so.* libclang.dylib* ycm_core.so $out/lib/ycmd/ 52 53 mkdir -p $out/bin 54 ln -s $out/lib/ycmd/ycmd/__main__.py $out/bin/ycmd 55 56 # Copy everything: the structure of third_party has been known to change. 57 # When linking our own libraries below, do so with '-f' 58 # to clobber anything we may have copied here. 59 mkdir -p $out/lib/ycmd/third_party 60 cp -r third_party/* $out/lib/ycmd/third_party/ 61 62 '' + lib.optionalString withGocode '' 63 TARGET=$out/lib/ycmd/third_party/gocode 64 mkdir -p $TARGET 65 ln -sf ${gocode}/bin/gocode $TARGET 66 '' + lib.optionalString withGodef '' 67 TARGET=$out/lib/ycmd/third_party/godef 68 mkdir -p $TARGET 69 ln -sf ${godef}/bin/godef $TARGET 70 '' + lib.optionalString withGotools '' 71 TARGET=$out/lib/ycmd/third_party/go/src/golang.org/x/tools/cmd/gopls 72 mkdir -p $TARGET 73 ln -sf ${gotools}/bin/gopls $TARGET 74 '' + lib.optionalString withTypescript '' 75 TARGET=$out/lib/ycmd/third_party/tsserver 76 ln -sf ${nodePackages.typescript} $TARGET 77 ''; 78 79 # fixup the argv[0] and replace __file__ with the corresponding path so 80 # python won't be thrown off by argv[0] 81 postFixup = '' 82 substituteInPlace $out/lib/ycmd/ycmd/__main__.py \ 83 --replace $out/lib/ycmd/ycmd/__main__.py $out/bin/ycmd \ 84 --replace __file__ "'$out/lib/ycmd/ycmd/__main__.py'" 85 ''; 86 87 meta = with 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}