Merge pull request #307098 from r-ryantm/auto-update/cilium-cli
[NixPkgs.git] / pkgs / development / python-modules / python-matter-server / default.nix
blobb157eba228acd6d5ab9399b576ec461f8b369a16
1 { lib
2 , buildPythonPackage
3 , fetchFromGitHub
4 , pythonOlder
5 , stdenvNoCC
6 , substituteAll
8 # build
9 , setuptools
10 , pythonRelaxDepsHook
12 # propagates
13 , aiohttp
14 , aiorun
15 , async-timeout
16 , coloredlogs
17 , dacite
18 , orjson
19 , home-assistant-chip-clusters
21 # optionals
22 , cryptography
23 , home-assistant-chip-core
24 , zeroconf
26 # tests
27 , python
28 , pytest
29 , pytest-aiohttp
30 , pytestCheckHook
33 let
34   paaCerts = stdenvNoCC.mkDerivation rec {
35     pname = "matter-server-paa-certificates";
36     version = "1.2.0.1";
38     src = fetchFromGitHub {
39       owner = "project-chip";
40       repo = "connectedhomeip";
41       rev = "refs/tags/v${version}";
42       hash = "sha256-p3P0n5oKRasYz386K2bhN3QVfN6oFndFIUWLEUWB0ss=";
43     };
45     installPhase = ''
46       runHook preInstall
48       mkdir -p $out
49       cp $src/credentials/development/paa-root-certs/* $out/
51       runHook postInstall
52     '';
53   };
56 buildPythonPackage rec {
57   pname = "python-matter-server";
58   version = "5.9.0";
59   format = "pyproject";
61   disabled = pythonOlder "3.10";
63   src = fetchFromGitHub {
64     owner = "home-assistant-libs";
65     repo = "python-matter-server";
66     rev = "refs/tags/${version}";
67     hash = "sha256-O3AJ7vBjuwRGa4AMwWIdxn5m2F45rLCjCHeff18b/5E=";
68   };
70   patches = [
71     (substituteAll {
72       src = ./link-paa-root-certs.patch;
73       paacerts = paaCerts;
74     })
75   ];
77   postPatch = ''
78     substituteInPlace pyproject.toml \
79       --replace 'version = "0.0.0"' 'version = "${version}"' \
80       --replace '--cov' ""
81   '';
83   nativeBuildInputs = [
84     setuptools
85     pythonRelaxDepsHook
86   ];
88   pythonRelaxDeps = [
89     "home-assistant-chip-clusters"
90   ];
92   propagatedBuildInputs = [
93     aiohttp
94     aiorun
95     async-timeout
96     coloredlogs
97     dacite
98     orjson
99     home-assistant-chip-clusters
100   ];
102   passthru.optional-dependencies = {
103     server = [
104       cryptography
105       home-assistant-chip-core
106       zeroconf
107     ];
108   };
110   nativeCheckInputs = [
111     pytest-aiohttp
112     pytestCheckHook
113   ]
114   ++ lib.flatten (lib.attrValues passthru.optional-dependencies);
116   preCheck = let
117     pythonEnv = python.withPackages (_: propagatedBuildInputs ++ nativeCheckInputs ++ [ pytest ]);
118   in
119   ''
120     export PYTHONPATH=${pythonEnv}/${python.sitePackages}
121   '';
123   pytestFlagsArray = [
124     # Upstream theymselves limit the test scope
125     # https://github.com/home-assistant-libs/python-matter-server/blob/main/.github/workflows/test.yml#L65
126     "tests/server"
127   ];
129   meta = with lib; {
130     changelog = "https://github.com/home-assistant-libs/python-matter-server/releases/tag/${version}";
131     description = "Python server to interact with Matter";
132     mainProgram = "matter-server";
133     homepage = "https://github.com/home-assistant-libs/python-matter-server";
134     license = licenses.asl20;
135     maintainers = teams.home-assistant.members;
136   };