lol
1{ lib, stdenv
2, fetchFromGitHub
3, fetchpatch
4, cmake
5, ninja
6, pkg-config
7, grpc
8, protobuf
9, openssl
10, nlohmann_json
11, gtest
12, spdlog
13, c-ares
14, zlib
15, sqlite
16, re2
17, lit
18, python3
19, coreutils
20}:
21
22stdenv.mkDerivation rec {
23 pname = "bear";
24 version = "3.1.3";
25
26 src = fetchFromGitHub {
27 owner = "rizsotto";
28 repo = pname;
29 rev = version;
30 hash = "sha256-1nZPzgLWcmaRkOUXdm16IW2Nw/p1w8GBGEfZX/v+En0=";
31 };
32
33 nativeBuildInputs = [
34 cmake
35 ninja
36 pkg-config
37
38 # Used for functional tests, which run during buildPhase.
39 lit
40 python3
41 ];
42
43 buildInputs = [
44 grpc
45 protobuf
46 openssl
47 nlohmann_json
48 gtest
49 spdlog
50 c-ares
51 zlib
52 sqlite
53 re2
54 ];
55
56 cmakeFlags = [
57 # Build system and generated files concatenate install prefix and
58 # CMAKE_INSTALL_{BIN,LIB}DIR, which breaks if these are absolute paths.
59 "-DCMAKE_INSTALL_BINDIR=bin"
60 "-DCMAKE_INSTALL_LIBDIR=lib"
61 (lib.cmakeBool "ENABLE_UNIT_TESTS" false)
62 (lib.cmakeBool "ENABLE_FUNC_TESTS" false)
63 ];
64
65 patches = [
66 # Fix toolchain environment variable handling and the Darwin SIP check.
67 ./fix-functional-tests.patch
68 ];
69
70 postPatch = ''
71 patchShebangs test/bin
72
73 # /usr/bin/env is used in test commands and embedded scripts.
74 find test -name '*.sh' \
75 -exec sed -ie 's|/usr/bin/env|${coreutils}/bin/env|g' {} +
76 '';
77
78 # Functional tests use loopback networking.
79 __darwinAllowLocalNetworking = true;
80
81 meta = with lib; {
82 description = "Tool that generates a compilation database for clang tooling";
83 mainProgram = "bear";
84 longDescription = ''
85 Note: the bear command is very useful to generate compilation commands
86 e.g. for YouCompleteMe. You just enter your development nix-shell
87 and run `bear make`. It's not perfect, but it gets a long way.
88 '';
89 homepage = "https://github.com/rizsotto/Bear";
90 license = licenses.gpl3Plus;
91 platforms = platforms.unix;
92 maintainers = with maintainers; [ babariviere DieracDelta ];
93 };
94}