1{
2 lib,
3 buildPythonPackage,
4 fetchFromGitHub,
5 pythonOlder,
6
7 # build-system
8 setuptools,
9
10 # codegen
11 hassil,
12 python,
13 pyyaml,
14 voluptuous,
15 regex,
16 jinja2,
17
18 # tests
19 pytest-xdist,
20 pytestCheckHook,
21}:
22
23buildPythonPackage rec {
24 pname = "home-assistant-intents";
25 version = "2025.6.23";
26 pyproject = true;
27
28 disabled = pythonOlder "3.9";
29
30 src = fetchFromGitHub {
31 owner = "home-assistant";
32 repo = "intents-package";
33 rev = "refs/tags/${version}";
34 fetchSubmodules = true;
35 hash = "sha256-0xFa4Xz2zjN5EQVd9XafkUvroAH4AIiF/9bqFAZcJ9U=";
36 };
37
38 build-system = [
39 setuptools
40
41 # build-time codegen; https://github.com/home-assistant/intents/blob/main/requirements.txt#L1-L5
42 hassil
43 pyyaml
44 voluptuous
45 regex
46 jinja2
47 ];
48
49 postInstall = ''
50 # https://github.com/home-assistant/intents-package/blob/main/script/package#L23-L24
51 PACKAGE_DIR=$out/${python.sitePackages}/home_assistant_intents
52 ${python.pythonOnBuildForHost.interpreter} script/merged_output.py $PACKAGE_DIR/data
53 ${python.pythonOnBuildForHost.interpreter} script/write_languages.py $PACKAGE_DIR/data > $PACKAGE_DIR/languages.py
54 '';
55
56 nativeCheckInputs = [
57 pytest-xdist
58 pytestCheckHook
59 ];
60
61 enabledTestPaths = [
62 "intents/tests"
63 ];
64
65 # requires hassil 3.0.0, but Home Assistant is stuck on 2.2.3
66 doCheck = false;
67
68 meta = with lib; {
69 changelog = "https://github.com/home-assistant/intents/releases/tag/${version}";
70 description = "Intents to be used with Home Assistant";
71 homepage = "https://github.com/home-assistant/intents";
72 license = licenses.cc-by-40;
73 teams = [ teams.home-assistant ];
74 };
75}