nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 stdenv,
4 buildPythonPackage,
5 fetchFromGitHub,
6 bluez,
7 pythonOlder,
8
9 # build-system
10 poetry-core,
11
12 # dependencies
13 bumble,
14 dbus-fast,
15 pyobjc-core,
16 pyobjc-framework-CoreBluetooth,
17 pyobjc-framework-libdispatch,
18 typing-extensions,
19 async-timeout,
20
21 pytest-asyncio,
22 pytest-cov-stub,
23 pytestCheckHook,
24}:
25
26buildPythonPackage rec {
27 pname = "bleak";
28 version = "2.0.0";
29 pyproject = true;
30
31 src = fetchFromGitHub {
32 owner = "hbldh";
33 repo = "bleak";
34 tag = "v${version}";
35 hash = "sha256-UrKJoEyLa75HMCOgxmOqJi1z+32buMra+dwVe5qbBds=";
36 };
37
38 postPatch =
39 # bleak checks BlueZ's version with a call to `bluetoothctl --version`
40 lib.optionalString stdenv.hostPlatform.isLinux ''
41 substituteInPlace bleak/backends/bluezdbus/version.py \
42 --replace-fail \
43 '"bluetoothctl"' \
44 '"${lib.getExe' bluez "bluetoothctl"}"'
45 '';
46
47 build-system = [ poetry-core ];
48
49 dependencies = [
50 ]
51 ++ lib.optionals stdenv.hostPlatform.isLinux [
52 dbus-fast
53 ]
54 ++ lib.optionals stdenv.hostPlatform.isDarwin [
55 pyobjc-core
56 pyobjc-framework-CoreBluetooth
57 pyobjc-framework-libdispatch
58 ]
59 ++ lib.optionals (pythonOlder "3.12") [
60 typing-extensions
61 ]
62 ++ lib.optionals (pythonOlder "3.11") [
63 async-timeout
64 ];
65
66 nativeCheckInputs = [
67 bumble
68 pytest-asyncio
69 pytest-cov-stub
70 pytestCheckHook
71 ];
72
73 pythonImportsCheck = [ "bleak" ];
74
75 meta = {
76 description = "Bluetooth Low Energy platform agnostic client";
77 homepage = "https://github.com/hbldh/bleak";
78 changelog = "https://github.com/hbldh/bleak/blob/${src.tag}/CHANGELOG.rst";
79 license = lib.licenses.mit;
80 platforms = lib.platforms.linux ++ lib.platforms.darwin;
81 maintainers = with lib.maintainers; [ oxzi ];
82 };
83}