1{
2 home-assistant,
3 makeSetupHook,
4}:
5
6{
7 owner,
8 domain,
9 version,
10 format ? "other",
11 ...
12}@args:
13
14let
15 manifestRequirementsCheckHook = import ./manifest-requirements-check-hook.nix {
16 inherit makeSetupHook;
17 inherit (home-assistant) python;
18 };
19in
20home-assistant.python.pkgs.buildPythonPackage (
21 {
22 pname = "${owner}/${domain}";
23 inherit version format;
24
25 buildPhase = ''
26 true
27 '';
28
29 installPhase = ''
30 runHook preInstall
31
32 mkdir $out
33 if [[ -f ./manifest.json ]]; then
34 mkdir $out/custom_components
35 cp -R "$(realpath .)" "$out/custom_components/${domain}"
36 else
37 cp -r ./custom_components/ $out/
38 fi
39
40 # optionally copy sentences, if they exist
41 if [[ -d ./custom_sentences ]]; then
42 cp -r ./custom_sentences/ $out/
43 fi
44
45 runHook postInstall
46 '';
47
48 nativeCheckInputs =
49 with home-assistant.python.pkgs;
50 [
51 manifestRequirementsCheckHook
52 packaging
53 ]
54 ++ (args.nativeCheckInputs or [ ]);
55
56 passthru = {
57 isHomeAssistantComponent = true;
58 }
59 // args.passthru or { };
60
61 meta = {
62 inherit (home-assistant.meta) platforms;
63 }
64 // args.meta or { };
65
66 }
67 // builtins.removeAttrs args [
68 "meta"
69 "nativeCheckInputs"
70 "passthru"
71 ]
72)