git.iko.soy/typeable/nixpkgs
on master help sign in
ycmd: use vendored python libs

YouCompleteMe needs the packages to be available in ycmd's third_party directory, and things start getting pretty complicated when we try to use our package libs instead of the vendored ones. We can revisit this at a later time, but we'll need to ensure that we don't break the vim plugin. Tested in vim.

commit53a5117cde14e1905cbe67e294f9b2b974dbe09a authorCharles Strahan <charles@cstrahan.com> dateThu 9 Feb 2017, 23:39 (10 years ago) parentb27edc4
3 files changed+64−24
pkgs/development/tools/misc/ycmd/2-ycm-cmake.patch+40 pkgs/development/tools/misc/ycmd/default.nix+20−23 pkgs/top-level/all-packages.nix+4−1
pkgs/development/tools/misc/ycmd/2-ycm-cmake.patchnew file+40
@@ -0,0 +1,40 @@
1+diff --git a/cpp/ycm/CMakeLists.txt b/cpp/ycm/CMakeLists.txt
2+index 2074c58e..9ecd6e57 100644
3+--- a/cpp/ycm/CMakeLists.txt
4++++ b/cpp/ycm/CMakeLists.txt
5+@@ -366,35 +366,6 @@ if( LIBCLANG_TARGET )
6+ POST_BUILD
7+ COMMAND ${CMAKE_COMMAND} -E copy "${LIBCLANG_TARGET}" "$<TARGET_FILE_DIR:${PROJECT_NAME}>"
8+ )
9+-
10+- if( APPLE )
11+- # In OS X El Capitan, Apple introduced System Integrity Protection.
12+- # Amongst other things, this introduces features to the dynamic loader
13+- # (dyld) which cause it to "sanitise" (and complain about) embedded
14+- # LC_RPATH entries which contain @executable_path when then are loaded
15+- # into "restricted" binaries. For our purposes, "restricted" here means
16+- # "supplied by Apple" and includes the system versions of python. For
17+- # unknown reasons, the libclang.dylib that comes from llvm.org includes an
18+- # LC_RPATH entry '@executable_path/../lib' which causes the OS X dynamic
19+- # loader to print a cryptic warning to stderr of the form:
20+- #
21+- # dyld: warning, LC_RPATH @executable_path/../lib in
22+- # /path/to/ycmd/libclang.dylib being ignored in restricted program
23+- # because of @executable_path
24+- #
25+- # In order to prevent this harmless and annoying message appearing, we
26+- # simply strip the rpath entry from the dylib. There's no way any
27+- # @executable_path that python might have could be in any way useful to
28+- # libclang.dylib, so this seems perfectly safe.
29+- get_filename_component( LIBCLANG_TAIL ${LIBCLANG_TARGET} NAME )
30+- add_custom_command( TARGET ${PROJECT_NAME}
31+- POST_BUILD
32+- COMMAND install_name_tool
33+- "-delete_rpath"
34+- "@executable_path/../lib"
35+- "$<TARGET_FILE_DIR:${PROJECT_NAME}>/${LIBCLANG_TAIL}"
36+- )
37+- endif()
38+ endif()
39+ endif()
40+
pkgs/development/tools/misc/ycmd/default.nix+20−23
@@ -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}
pkgs/top-level/all-packages.nix+4−1
@@ -6785,7 +6785,10 @@ with pkgs;
67856785
67866786 yacc = bison;
67876787
6788− ycmd = callPackage ../development/tools/misc/ycmd { };
6788+ ycmd = callPackage ../development/tools/misc/ycmd {
6789+ inherit (darwin.apple_sdk.frameworks) Cocoa;
6790+ python = python2;
6791+ };
67896792
67906793 yodl = callPackage ../development/tools/misc/yodl { };
67916794