1{ lib, stdenv, fetchpatch, fetchFromGitHub
2, cmake, git
3, asio, catch2, spdlog
4, IOKit, udev
5}:
6
7stdenv.mkDerivation rec {
8 pname = "pc-ble-driver";
9 version = "4.1.4";
10
11 src = fetchFromGitHub {
12 owner = "NordicSemiconductor";
13 repo = pname;
14 rev = "v${version}";
15 hash = "sha256-srH7Gdiy9Lsv68fst/9jhifx03R2e+4kMia6pU/oCZg=";
16 };
17
18 patches = [
19 (fetchpatch {
20 name = "support-arm.patch";
21 url = "https://github.com/NordicSemiconductor/pc-ble-driver/commit/76a6b31dba7a13ceae40587494cbfa01a29192f4.patch";
22 hash = "sha256-bvK1BXjdlhIXV8R4PiCGaq8oSLzgjMmTgAwssm8N2sk=";
23 })
24 # Fix build with GCC 11
25 (fetchpatch {
26 url = "https://github.com/NordicSemiconductor/pc-ble-driver/commit/37258e65bdbcd0b4369ae448faf650dd181816ec.patch";
27 hash = "sha256-gOdzIW8YJQC+PE4FJd644I1+I7CMcBY8wpF6g02eI5g=";
28 })
29 ];
30
31 cmakeFlags = [
32 "-DNRF_BLE_DRIVER_VERSION=${version}"
33 ] ++ lib.optionals (stdenv.isDarwin && stdenv.isAarch64) [
34 "-DARCH=arm64"
35 ];
36
37 nativeBuildInputs = [ cmake git ];
38 buildInputs = [ asio catch2 spdlog ];
39
40 propagatedBuildInputs = [
41
42 ] ++ lib.optionals stdenv.isDarwin [
43 IOKit
44 ] ++ lib.optionals stdenv.isLinux [
45 udev
46 ];
47
48 meta = with lib; {
49 description = "Desktop library for Bluetooth low energy development";
50 homepage = "https://github.com/NordicSemiconductor/pc-ble-driver";
51 license = licenses.unfreeRedistributable;
52 platforms = platforms.unix;
53 };
54}