nixpkgs/pkgs/by-name/be/bear/package.nix
Winter a19cd4ffb1 Revert "treewide: replace rev with tag"
This reverts commit 65a333600d5c88a98d674f637d092807cfc12253.

This wasn't tested for correctness with something like fodwatch [0],
and should not have been (self-)merged so quickly, especially without
further review.

It also resulted in the breakage of at least one package [1] (and that's
the one we know of and was caught).

A few packages that were updated in between this commit and this revert
were not reverted back to using `rev`, but other than that, this is a
1:1 revert.

[0]: https://codeberg.org/raphaelr/fodwatch
[1]: https://github.com/NixOS/nixpkgs/pull/396904 / 758551e4587d75882aebc21a04bee960418f8ce9
2025-04-08 02:57:25 -04:00

127 lines
3.0 KiB
Nix

{
lib,
stdenv,
fetchFromGitHub,
cmake,
ninja,
pkg-config,
grpc,
protobuf,
openssl,
nlohmann_json,
gtest,
spdlog,
c-ares,
zlib,
sqlite,
re2,
lit,
python3,
coreutils,
}:
stdenv.mkDerivation (finalAttrs: {
pname = "bear";
version = "3.1.6";
src = fetchFromGitHub {
owner = "rizsotto";
repo = "bear";
rev = finalAttrs.version;
hash = "sha256-fWNMjqF5PCjGfFGReKIUiJ5lv8z6j7HeBn5hvbnV2V4=";
};
strictDeps = true;
nativeBuildInputs = [
cmake
ninja
pkg-config
grpc
protobuf
];
buildInputs = [
grpc
protobuf
openssl
nlohmann_json
spdlog
c-ares
zlib
sqlite
re2
];
patches = [
# This patch is necessary to run tests in a separate phase. By default
# test targets are run with ALL, which is not what we want. This patch creates
# separate 'test' step targets for each cmake ExternalProject:
# - BearTest-test (functional lit tests)
# - BearSource-test (unit tests via gtest)
./0001-exclude-tests-from-all.patch
];
nativeCheckInputs = [
lit
python3
];
checkInputs = [
gtest
];
cmakeFlags = [
# Build system and generated files concatenate install prefix and
# CMAKE_INSTALL_{BIN,LIB}DIR, which breaks if these are absolute paths.
(lib.cmakeFeature "CMAKE_INSTALL_BINDIR" "bin")
(lib.cmakeFeature "CMAKE_INSTALL_LIBDIR" "lib")
(lib.cmakeBool "ENABLE_UNIT_TESTS" finalAttrs.finalPackage.doCheck)
(lib.cmakeBool "ENABLE_FUNC_TESTS" finalAttrs.finalPackage.doCheck)
];
checkTarget = lib.concatStringsSep " " [
"BearTest-test"
"BearSource-test"
];
doCheck = true;
env = {
# Disable failing tests. The cause is not immediately clear.
LIT_FILTER_OUT = lib.concatStringsSep "|" [
"cases/compilation/output/config/filter_compilers.sh"
"cases/intercept/preload/posix/execvpe/success_to_resolve.c"
"cases/intercept/preload/posix/popen/success.c"
"cases/intercept/preload/posix/posix_spawnp/success_to_resolve.c"
"cases/intercept/preload/posix/system/success.c"
"cases/intercept/preload/shell_commands_intercepted_without_shebang.sh"
];
};
postPatch = ''
patchShebangs test/bin
# /usr/bin/env is used in test commands and embedded scripts.
find test -name '*.sh' \
-exec sed -i -e 's|/usr/bin/env|${coreutils}/bin/env|g' {} +
'';
# Functional tests use loopback networking.
__darwinAllowLocalNetworking = true;
meta = {
description = "Tool that generates a compilation database for clang tooling";
mainProgram = "bear";
longDescription = ''
Note: the bear command is very useful to generate compilation commands
e.g. for YouCompleteMe. You just enter your development nix-shell
and run `bear make`. It's not perfect, but it gets a long way.
'';
homepage = "https://github.com/rizsotto/Bear";
license = lib.licenses.gpl3Plus;
platforms = lib.platforms.unix;
maintainers = with lib.maintainers; [ DieracDelta ];
};
})