1{ lib
2, stdenv
3, fetchFromGitHub
4, catch2
5, cmake
6, expected-lite
7, fmt
8, gsl-lite
9, ninja
10}:
11
12stdenv.mkDerivation rec {
13 pname = "bencode";
14 version = "1.0.1";
15
16 src = fetchFromGitHub {
17 owner = "fbdtemme";
18 repo = "bencode";
19 rev = version;
20 hash = "sha256-zpxvADZfYTUdlNLMZJSCanPL40EGl9BBCxR7oDhvOTw=";
21 };
22
23 nativeBuildInputs = [
24 cmake
25 ninja
26 ];
27
28 buildInputs = [
29 catch2
30 expected-lite
31 fmt
32 gsl-lite
33 ];
34
35 postPatch = ''
36 # Disable a test that requires an internet connection.
37 substituteInPlace tests/CMakeLists.txt \
38 --replace "add_subdirectory(cmake_fetch_content)" ""
39 '';
40
41 doCheck = true;
42
43 postInstall = ''
44 rm -rf $out/lib64
45 '';
46
47 meta = with lib; {
48 description = "A header-only C++20 bencode serialization/deserialization library";
49 homepage = "https://github.com/fbdtemme/bencode";
50 changelog = "https://github.com/fbdtemme/bencode/blob/${src.rev}/CHANGELOG.md";
51 license = licenses.mit;
52 maintainers = with maintainers; [ azahi ];
53 platforms = platforms.unix;
54 # Broken because the default stdenv on these targets doesn't support C++20.
55 broken = with stdenv; isDarwin || (isLinux && isAarch64);
56 };
57}