Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{
2 lib,
3 stdenv,
4 fetchFromGitHub,
5 cmake,
6 ninja,
7 pkg-config,
8 grpc,
9 protobuf,
10 openssl,
11 nlohmann_json,
12 gtest,
13 spdlog,
14 c-ares,
15 zlib,
16 sqlite,
17 re2,
18 lit,
19 python3,
20 coreutils,
21}:
22
23stdenv.mkDerivation (finalAttrs: {
24 pname = "bear";
25 version = "3.1.6";
26
27 src = fetchFromGitHub {
28 owner = "rizsotto";
29 repo = "bear";
30 rev = finalAttrs.version;
31 hash = "sha256-fWNMjqF5PCjGfFGReKIUiJ5lv8z6j7HeBn5hvbnV2V4=";
32 };
33
34 strictDeps = true;
35
36 nativeBuildInputs = [
37 cmake
38 ninja
39 pkg-config
40 grpc
41 protobuf
42 ];
43
44 buildInputs = [
45 grpc
46 protobuf
47 openssl
48 nlohmann_json
49 spdlog
50 c-ares
51 zlib
52 sqlite
53 re2
54 ];
55
56 patches = [
57 # This patch is necessary to run tests in a separate phase. By default
58 # test targets are run with ALL, which is not what we want. This patch creates
59 # separate 'test' step targets for each cmake ExternalProject:
60 # - BearTest-test (functional lit tests)
61 # - BearSource-test (unit tests via gtest)
62 ./0001-exclude-tests-from-all.patch
63 ];
64
65 nativeCheckInputs = [
66 lit
67 python3
68 ];
69
70 checkInputs = [
71 gtest
72 ];
73
74 cmakeFlags = [
75 # Build system and generated files concatenate install prefix and
76 # CMAKE_INSTALL_{BIN,LIB}DIR, which breaks if these are absolute paths.
77 (lib.cmakeFeature "CMAKE_INSTALL_BINDIR" "bin")
78 (lib.cmakeFeature "CMAKE_INSTALL_LIBDIR" "lib")
79 (lib.cmakeBool "ENABLE_UNIT_TESTS" finalAttrs.finalPackage.doCheck)
80 (lib.cmakeBool "ENABLE_FUNC_TESTS" finalAttrs.finalPackage.doCheck)
81 ];
82
83 checkTarget = lib.concatStringsSep " " [
84 "BearTest-test"
85 "BearSource-test"
86 ];
87
88 doCheck = true;
89
90 env = {
91 # Disable failing tests. The cause is not immediately clear.
92 LIT_FILTER_OUT = lib.concatStringsSep "|" [
93 "cases/compilation/output/config/filter_compilers.sh"
94 "cases/intercept/preload/posix/execvpe/success_to_resolve.c"
95 "cases/intercept/preload/posix/popen/success.c"
96 "cases/intercept/preload/posix/posix_spawnp/success_to_resolve.c"
97 "cases/intercept/preload/posix/system/success.c"
98 "cases/intercept/preload/shell_commands_intercepted_without_shebang.sh"
99 ];
100 };
101
102 postPatch = ''
103 patchShebangs test/bin
104
105 # /usr/bin/env is used in test commands and embedded scripts.
106 find test -name '*.sh' \
107 -exec sed -i -e 's|/usr/bin/env|${coreutils}/bin/env|g' {} +
108 '';
109
110 # Functional tests use loopback networking.
111 __darwinAllowLocalNetworking = true;
112
113 meta = {
114 description = "Tool that generates a compilation database for clang tooling";
115 mainProgram = "bear";
116 longDescription = ''
117 Note: the bear command is very useful to generate compilation commands
118 e.g. for YouCompleteMe. You just enter your development nix-shell
119 and run `bear make`. It's not perfect, but it gets a long way.
120 '';
121 homepage = "https://github.com/rizsotto/Bear";
122 license = lib.licenses.gpl3Plus;
123 platforms = lib.platforms.unix;
124 maintainers = with lib.maintainers; [ DieracDelta ];
125 };
126})