nixpkgs/pkgs/servers/home-assistant/custom-components
Martin Weinelt 3688a3431f
Merge pull request #285149 from rhoriguchi/localtuya
home-assistant-custom-components.localtuya: init at 5.2.1
2024-02-08 23:17:08 +01:00
..
adaptive_lighting home-assistant-custom-components.adaptive_lighting: init at 1.19.1 2023-12-07 16:25:26 +01:00
emporia_vue home-assistant-custom-components.emporia_vue: init at 0.8.3 2024-02-06 19:18:37 -08:00
govee-lan home-assistant.custom-components.govee-lan: init at unstable-2023-06-10 2023-12-08 13:13:01 +01:00
gpio home-assistant-custom-components.gpio: init at 0.0.2 2024-01-21 12:00:10 +01:00
localtuya home-assistant-custom-components.localtuya: init at 5.2.1 2024-01-31 00:25:24 +01:00
miele
prometheus_sensor
waste_collection_schedule home-assistant-custom-components.waste_collection_schedule: init at 1.44.0 2023-12-18 10:46:18 -08:00
default.nix Merge pull request #285149 from rhoriguchi/localtuya 2024-02-08 23:17:08 +01:00
README.md buildHomeAssistantComponent: fix readme syntax 2024-01-10 13:43:59 +01:00

Packaging guidelines

buildHomeAssistantComponent

Custom components should be packaged using the buildHomeAssistantComponent function, that is provided at top-level. It builds upon buildPythonPackage but uses a custom install and check phase.

Python runtime dependencies can be directly consumed as unqualified function arguments. Pass them into propagatedBuildInputs, for them to be available to Home Assistant.

Out-of-tree components need to use python packages from home-assistant.python.pkgs as to not introduce conflicting package versions into the Python environment.

Example Boilerplate:

{ lib
, buildHomeAssistantcomponent
, fetchFromGitHub
}:

buildHomeAssistantComponent {
  # owner, domain, version

  src = fetchFromGithub {
    # owner, repo, rev, hash
  };

  propagatedBuildInputs = [
    # python requirements, as specified in manifest.json
  ];

  meta = with lib; {
    # changelog, description, homepage, license, maintainers
  }
}

Package attribute

The attribute name must reflect the domain as seen in the manifest.json, which in turn will match the python module name below in the custom_components/ directory.

Example:

The project mweinelt/ha-prometheus-sensor would receive the attribute name "prometheus_sensor", because both domain in the manifest.json as well as the module name are prometheus_sensor.

Package name

The pname attribute is a composition of both owner and domain.

Don't set pname, set owner and domain` instead.

Exposing the domain attribute separately allows checking for conflicting components at eval time.

Manifest check

The buildHomeAssistantComponent builder uses a hook to check whether the dependencies specified in the manifest.json are present and inside the specified version range. It also makes sure derivation and manifest agree about the domain name.

There shouldn't be a need to disable this hook, but you can set dontCheckManifest to true in the derivation to achieve that.