nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at python-updates 144 lines 3.9 kB view raw
1{ 2 stdenv, 3 lib, 4 fetchFromGitHub, 5 cmake, 6 ninja, 7 python3, 8 withGodef ? true, 9 godef, 10 withGopls ? true, 11 gopls, 12 withRustAnalyzer ? true, 13 rust-analyzer, 14 withTypescript ? true, 15 typescript, 16 abseil-cpp, 17 boost, 18 llvmPackages, 19 fixDarwinDylibNames, 20}: 21 22stdenv.mkDerivation { 23 pname = "ycmd"; 24 version = "0-unstable-2025-10-24"; 25 26 # required for third_party directory creation 27 src = fetchFromGitHub { 28 owner = "ycm-core"; 29 repo = "ycmd"; 30 rev = "7895484ad55e0cbd0686e882891d59661f183476"; 31 hash = "sha256-MSzYX1vXuhd4TNxUfHWaRu7O0r89az1XjZBIZ6B3gBk="; 32 fetchSubmodules = true; 33 }; 34 35 nativeBuildInputs = [ 36 cmake 37 ninja 38 ] 39 ++ lib.optional stdenv.hostPlatform.isDarwin fixDarwinDylibNames; 40 buildInputs = 41 with python3.pkgs; 42 with llvmPackages; 43 [ 44 abseil-cpp 45 boost 46 libllvm.all 47 libclang.all 48 legacy-cgi 49 ] 50 ++ [ 51 jedi 52 jedi-language-server 53 ]; 54 55 buildPhase = '' 56 export EXTRA_CMAKE_ARGS="-DPATH_TO_LLVM_ROOT=${llvmPackages.libllvm} -DUSE_SYSTEM_ABSEIL=true" 57 ${python3.pythonOnBuildForHost.interpreter} build.py --system-libclang --clang-completer --ninja 58 ''; 59 60 dontConfigure = true; 61 62 # remove the tests 63 # 64 # make __main__.py executable and add shebang 65 # 66 # copy over third-party libs 67 # note: if we switch to using our packaged libs, we'll need to symlink them 68 # into the same spots, as YouCompleteMe (the vim plugin) expects those paths 69 # to be available 70 # 71 # symlink completion backends where ycmd expects them 72 installPhase = '' 73 rm -rf ycmd/tests 74 find third_party -type d -name "test" -exec rm -rf {} + 75 76 chmod +x ycmd/__main__.py 77 sed -i "1i #!${python3.interpreter}\ 78 " ycmd/__main__.py 79 80 mkdir -p $out/lib/ycmd 81 cp -r ycmd/ CORE_VERSION *.so* *.dylib* $out/lib/ycmd/ 82 83 mkdir -p $out/bin 84 ln -s $out/lib/ycmd/ycmd/__main__.py $out/bin/ycmd 85 86 ## Work-around CMake/Nix naming of `.so` output 87 ln -s $out/lib/ycmd/ycm_core.cpython-[[:digit:]-][^[:space:]]*-gnu${stdenv.hostPlatform.extensions.sharedLibrary} $out/lib/ycmd/ycm_core.so 88 89 # Copy everything: the structure of third_party has been known to change. 90 # When linking our own libraries below, do so with '-f' 91 # to clobber anything we may have copied here. 92 mkdir -p $out/lib/ycmd/third_party 93 cp -r third_party/* $out/lib/ycmd/third_party/ 94 95 '' 96 + lib.optionalString withGodef '' 97 TARGET=$out/lib/ycmd/third_party/godef 98 mkdir -p $TARGET 99 ln -sf ${godef}/bin/godef $TARGET 100 '' 101 + lib.optionalString withGopls '' 102 TARGET=$out/lib/ycmd/third_party/go/bin 103 mkdir -p $TARGET 104 ln -sf ${gopls}/bin/gopls $TARGET 105 '' 106 + lib.optionalString withRustAnalyzer '' 107 TARGET=$out/lib/ycmd/third_party/rust-analyzer 108 mkdir -p $TARGET 109 ln -sf ${rust-analyzer} $TARGET 110 '' 111 + lib.optionalString withTypescript '' 112 TARGET=$out/lib/ycmd/third_party/tsserver 113 ln -sf ${typescript} $TARGET 114 ''; 115 116 # fixup the argv[0] and replace __file__ with the corresponding path so 117 # python won't be thrown off by argv[0] 118 postFixup = '' 119 substituteInPlace $out/lib/ycmd/ycmd/__main__.py \ 120 --replace __file__ "'$out/lib/ycmd/ycmd/__main__.py'" 121 ''; 122 123 meta = { 124 description = "Code-completion and comprehension server"; 125 longDescription = '' 126 Note if YouCompleteMe Vim plugin complains with; 127 128 > ImportError: Python version mismatch: module was compiled for Python 3.13, but the interpreter version is incompatible: 3.10.18 129 130 ... then set something similar to following in `programs.vim.extraConfig`; 131 132 let g:ycm_server_python_interpreter = "''${python3.interpreter}" 133 ''; 134 mainProgram = "ycmd"; 135 homepage = "https://github.com/ycm-core/ycmd"; 136 license = lib.licenses.gpl3; 137 maintainers = with lib.maintainers; [ 138 lnl7 139 mel 140 S0AndS0 141 ]; 142 platforms = lib.platforms.all; 143 }; 144}