@@ -0,0 +1,54 @@
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+ postFixup = ''
31+ # We need to tell cquery where to find the standard library headers.
32+
33+ args="\"-isystem\", \"${if (stdenv.hostPlatform.libc == "glibc") then stdenv.cc.libc.dev else stdenv.cc.libc}/include\""
34+ args+=", \"-isystem\", \"${llvmPackages.libcxx}/include/c++/v1\""
35+
36+ wrapProgram $out/bin/cquery \
37+ --add-flags "'"'--init={"extraClangArguments": ['"''${args}"']}'"'"
38+ '';
39+
40+ doInstallCheck = true;
41+ installCheckPhase = ''
42+ pushd ${src}
43+ $out/bin/cquery --ci --clang-sanity-check && \
44+ $out/bin/cquery --ci --test-unit
45+ '';
46+
47+ meta = with stdenv.lib; {
48+ description = "A c/c++ language server powered by libclang";
49+ homepage = https://github.com/cquery-project/cquery;
50+ license = licenses.mit;
51+ platforms = platforms.linux ++ platforms.darwin;
52+ maintainers = [ maintainers.tobim ];
53+ };
54+}