@@ -0,0 +1,61 @@
1+{ stdenv, fetchFromGitHub, makeWrapper
2+, cmake, llvmPackages, ncurses }:
3+
4+let
5+ src = fetchFromGitHub {
6+ owner = "cquery-project";
7+ repo = "cquery";
8+ rev = "e45a9ebbb6d8bfaf8bf1a3135b6faa910afea37e";
9+ sha256 = "049gkqbamq4r2nz9yjcwq369zrmwrikzbhfza2x2vndqzaavq5yg";
10+ fetchSubmodules = true;
11+ };
12+
13+ stdenv = llvmPackages.stdenv;
14+
15+in
16+stdenv.mkDerivation rec {
17+ name = "cquery-${version}";
18+ version = "2018-03-25";
19+
20+ inherit src;
21+
22+ nativeBuildInputs = [ cmake makeWrapper ];
23+ buildInputs = with llvmPackages; [ clang clang-unwrapped llvm ncurses ];
24+
25+ cmakeFlags = [
26+ "-DSYSTEM_CLANG=ON"
27+ "-DCLANG_CXX=ON"
28+ ];
29+
30+ shell = stdenv.shell;
31+ postFixup = ''
32+ # We need to tell cquery where to find the standard library headers.
33+
34+ standard_library_includes="\\\"-isystem\\\", \\\"${if (stdenv.hostPlatform.libc == "glibc") then stdenv.cc.libc.dev else stdenv.cc.libc}/include\\\""
35+ standard_library_includes+=", \\\"-isystem\\\", \\\"${llvmPackages.libcxx}/include/c++/v1\\\""
36+ export standard_library_includes
37+
38+ wrapped=".cquery-wrapped"
39+ export wrapped
40+
41+ mv $out/bin/cquery $out/bin/$wrapped
42+ substituteAll ${./wrapper} $out/bin/cquery
43+ chmod --reference=$out/bin/$wrapped $out/bin/cquery
44+ '';
45+
46+ doInstallCheck = true;
47+ installCheckPhase = ''
48+ pushd ${src}
49+ $out/bin/cquery --ci --clang-sanity-check && \
50+ $out/bin/cquery --ci --test-unit
51+ '';
52+
53+ meta = with stdenv.lib; {
54+ description = "A c/c++ language server powered by libclang";
55+ homepage = https://github.com/cquery-project/cquery;
56+ license = licenses.mit;
57+ platforms = platforms.linux ++ platforms.darwin;
58+ maintainers = [ maintainers.tobim ];
59+ priority = 3;
60+ };
61+}