about summary refs log tree commit diff
path: root/nixpkgs/pkgs/servers/home-assistant/build-custom-component/default.nix
diff options
context:
space:
mode:
Diffstat (limited to 'nixpkgs/pkgs/servers/home-assistant/build-custom-component/default.nix')
-rw-r--r--nixpkgs/pkgs/servers/home-assistant/build-custom-component/default.nix40
1 files changed, 40 insertions, 0 deletions
diff --git a/nixpkgs/pkgs/servers/home-assistant/build-custom-component/default.nix b/nixpkgs/pkgs/servers/home-assistant/build-custom-component/default.nix
new file mode 100644
index 000000000000..2948d15bb814
--- /dev/null
+++ b/nixpkgs/pkgs/servers/home-assistant/build-custom-component/default.nix
@@ -0,0 +1,40 @@
+{ 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/
+
+      runHook postInstall
+    '';
+
+    nativeCheckInputs = with home-assistant.python.pkgs; [
+      importlib-metadata
+      manifestRequirementsCheckHook
+      packaging
+    ] ++ (args.nativeCheckInputs or []);
+
+  } // builtins.removeAttrs args [ "nativeCheckInputs" ]
+)