nixpkgs/pkgs/servers/home-assistant/build-custom-component/default.nix
Zhong Jianxin 6942502662 buildHomeAssistantComponent: inherit meta.platforms from home-assistant
home-assistant-custom-components.* are meant to be used with home-assistant,
they should be built for the same platforms as home-assistant.

Currently home-assistant is [Linux only][1], this will prevent
home-assistant-custom-component.* from building on Darwin, and save some build resources.

[1]: 87a30cbaa0/pkgs/servers/home-assistant/default.nix (L675)
2024-11-11 20:54:06 +08:00

52 lines
1.0 KiB
Nix

{ lib
, home-assistant
, makeSetupHook
}:
{ owner
, domain
, version
, format ? "other"
, ...
}@args:
let
manifestRequirementsCheckHook = import ./manifest-requirements-check-hook.nix {
inherit makeSetupHook;
inherit (home-assistant) python;
};
in
home-assistant.python.pkgs.buildPythonPackage (
{
pname = "${owner}/${domain}";
inherit format;
installPhase = ''
runHook preInstall
mkdir $out
cp -r ./custom_components/ $out/
# optionally copy sentences, if they exist
cp -r ./custom_sentences/ $out/ || true
runHook postInstall
'';
nativeCheckInputs = with home-assistant.python.pkgs; [
importlib-metadata
manifestRequirementsCheckHook
packaging
] ++ (args.nativeCheckInputs or []);
passthru = {
isHomeAssistantComponent = true;
} // args.passthru or { };
meta = {
inherit (home-assistant.meta) platforms;
} // args.meta or { };
} // builtins.removeAttrs args [ "meta" "nativeCheckInputs" "passthru" ]
)