about summary refs log tree commit diff
path: root/nixpkgs/pkgs/servers/home-assistant/build-custom-component/default.nix
blob: 2948d15bb8144ee6c210755dc79603aa427e331a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
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" ]
)