1{
2 lib,
3 stdenv,
4 buildPythonPackage,
5 fetchFromGitHub,
6 pythonRelaxDepsHook,
7
8 # build-system
9 setuptools,
10
11 # dependencies
12 async-timeout,
13 bellows,
14 click,
15 coloredlogs,
16 crc,
17 libgpiod,
18 typing-extensions,
19 zigpy,
20
21 # tests
22 pytestCheckHook,
23 pytest-asyncio,
24 pytest-mock,
25 pytest-timeout,
26}:
27
28buildPythonPackage rec {
29 pname = "universal-silabs-flasher";
30 version = "0.0.19";
31 pyproject = true;
32
33 src = fetchFromGitHub {
34 owner = "NabuCasa";
35 repo = "universal-silabs-flasher";
36 rev = "refs/tags/v${version}";
37 hash = "sha256-VoO9B27CNY2Cnt/Q2HsU6DVYkukQMgbIHc6xqfN0P7w=";
38 };
39
40 postPatch = ''
41 substituteInPlace pyproject.toml \
42 --replace-fail '"setuptools-git-versioning<2"' "" \
43 --replace-fail 'dynamic = ["version"]' 'version = "${version}"'
44 '';
45
46 nativeBuildInputs = [ pythonRelaxDepsHook ];
47
48 build-system = [ setuptools ];
49
50 pythonRelaxDeps = [
51 # https://github.com/NabuCasa/universal-silabs-flasher/pull/50
52 "gpiod"
53 ];
54
55 propagatedBuildInputs = [
56 async-timeout
57 bellows
58 click
59 coloredlogs
60 crc
61 typing-extensions
62 zigpy
63 ] ++ lib.optionals (stdenv.hostPlatform.isLinux) [ libgpiod ];
64
65 nativeCheckInputs = [
66 pytestCheckHook
67 pytest-asyncio
68 pytest-mock
69 pytest-timeout
70 ];
71
72 pythonImportsCheck = [ "universal_silabs_flasher" ];
73
74 meta = with lib; {
75 changelog = "https://github.com/NabuCasa/universal-silabs-flasher/releases/tag/v${version}";
76 description = "Flashes Silicon Labs radios running EmberZNet or CPC multi-pan firmware";
77 mainProgram = "universal-silabs-flasher";
78 homepage = "https://github.com/NabuCasa/universal-silabs-flasher";
79 license = licenses.gpl3Only;
80 maintainers = with maintainers; [ hexa ];
81 };
82}