Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ 2 lib, 3 buildPythonPackage, 4 fetchFromGitHub, 5 pythonOlder, 6 stdenvNoCC, 7 substituteAll, 8 9 # build 10 setuptools, 11 12 # propagates 13 aiohttp, 14 aiorun, 15 async-timeout, 16 coloredlogs, 17 dacite, 18 orjson, 19 home-assistant-chip-clusters, 20 21 # optionals 22 cryptography, 23 home-assistant-chip-core, 24 zeroconf, 25 26 # tests 27 python, 28 pytest, 29 pytest-aiohttp, 30 pytestCheckHook, 31}: 32 33let 34 paaCerts = stdenvNoCC.mkDerivation rec { 35 pname = "matter-server-paa-certificates"; 36 version = "1.3.0.0"; 37 38 src = fetchFromGitHub { 39 owner = "project-chip"; 40 repo = "connectedhomeip"; 41 rev = "refs/tags/v${version}"; 42 hash = "sha256-5MI6r0KhSTzolesTQ8YWeoko64jFu4jHfO5KOOKpV0A="; 43 }; 44 45 installPhase = '' 46 runHook preInstall 47 48 mkdir -p $out 49 cp $src/credentials/development/paa-root-certs/* $out/ 50 51 runHook postInstall 52 ''; 53 }; 54in 55 56buildPythonPackage rec { 57 pname = "python-matter-server"; 58 version = "6.2.2"; 59 pyproject = true; 60 61 disabled = pythonOlder "3.10"; 62 63 src = fetchFromGitHub { 64 owner = "home-assistant-libs"; 65 repo = "python-matter-server"; 66 rev = "refs/tags/${version}"; 67 hash = "sha256-20heZrdSuKfiRuKKnDyguSC5bbV/9qBcu6E/5vcV1iU="; 68 }; 69 70 patches = [ 71 (substituteAll { 72 src = ./link-paa-root-certs.patch; 73 paacerts = paaCerts; 74 }) 75 ]; 76 77 postPatch = '' 78 substituteInPlace pyproject.toml \ 79 --replace 'version = "0.0.0"' 'version = "${version}"' \ 80 --replace '--cov' "" 81 ''; 82 83 build-system = [ 84 setuptools 85 ]; 86 87 pythonRelaxDeps = [ "home-assistant-chip-clusters" ]; 88 89 dependencies = [ 90 aiohttp 91 aiorun 92 async-timeout 93 coloredlogs 94 dacite 95 orjson 96 home-assistant-chip-clusters 97 ]; 98 99 optional-dependencies = { 100 server = [ 101 cryptography 102 home-assistant-chip-core 103 zeroconf 104 ]; 105 }; 106 107 nativeCheckInputs = [ 108 pytest-aiohttp 109 pytestCheckHook 110 ] ++ lib.flatten (lib.attrValues optional-dependencies); 111 112 preCheck = 113 let 114 pythonEnv = python.withPackages (_: dependencies ++ nativeCheckInputs ++ [ pytest ]); 115 in 116 '' 117 export PYTHONPATH=${pythonEnv}/${python.sitePackages} 118 ''; 119 120 pytestFlagsArray = [ 121 # Upstream theymselves limit the test scope 122 # https://github.com/home-assistant-libs/python-matter-server/blob/main/.github/workflows/test.yml#L65 123 "tests/server" 124 ]; 125 126 meta = with lib; { 127 changelog = "https://github.com/home-assistant-libs/python-matter-server/releases/tag/${version}"; 128 description = "Python server to interact with Matter"; 129 mainProgram = "matter-server"; 130 homepage = "https://github.com/home-assistant-libs/python-matter-server"; 131 license = licenses.asl20; 132 maintainers = teams.home-assistant.members; 133 }; 134}