summary refs log tree commit diff
path: root/pkgs/servers/home-assistant/build-custom-component/default.nix
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/servers/home-assistant/build-custom-component/default.nix')
-rw-r--r--pkgs/servers/home-assistant/build-custom-component/default.nix38
1 files changed, 38 insertions, 0 deletions
diff --git a/pkgs/servers/home-assistant/build-custom-component/default.nix b/pkgs/servers/home-assistant/build-custom-component/default.nix
new file mode 100644
index 00000000000..05b7c2d4b03
--- /dev/null
+++ b/pkgs/servers/home-assistant/build-custom-component/default.nix
@@ -0,0 +1,38 @@
+{ lib
+, home-assistant
+, makeSetupHook
+}:
+
+{ pname
+, version
+, format ? "other"
+, ...
+}@args:
+
+let
+  manifestRequirementsCheckHook = import ./manifest-requirements-check-hook.nix {
+    inherit makeSetupHook;
+    inherit (home-assistant) python;
+  };
+in
+home-assistant.python.pkgs.buildPythonPackage (
+  {
+    inherit format;
+
+    installPhase = ''
+      runHook preInstall
+
+      mkdir $out
+      cp -r $src/custom_components/ $out/
+
+      runHook postInstall
+    '';
+
+    nativeCheckInputs = with home-assistant.python.pkgs; [
+      importlib-metadata
+      manifestRequirementsCheckHook
+      packaging
+    ] ++ (args.nativeCheckInputs or []);
+
+  } // builtins.removeAttrs args [ "nativeCheckInputs" ]
+)