1{
2 lib,
3 stdenv,
4 fetchFromGitHub,
5 python3,
6 installShellFiles,
7}:
8
9python3.pkgs.buildPythonApplication rec {
10 pname = "homeassistant-cli";
11 version = "0.9.6";
12 format = "setuptools";
13
14 src = fetchFromGitHub {
15 owner = "home-assistant-ecosystem";
16 repo = "home-assistant-cli";
17 rev = version;
18 hash = "sha256-4OeHJ7icDZUOC5K4L0F0Nd9lbJPgdW4LCU0wniLvJ1Q=";
19 };
20
21 postPatch = ''
22 # Ignore pinned versions
23 sed -i "s/'\(.*\)\(==\|>=\).*'/'\1'/g" setup.py
24 '';
25
26 propagatedBuildInputs = with python3.pkgs; [
27 aiohttp
28 click
29 click-log
30 dateparser
31 jinja2
32 jsonpath-ng
33 netdisco
34 regex
35 requests
36 ruamel-yaml
37 tabulate
38 ];
39
40 postInstall = lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
41 installShellCompletion --cmd hass-cli \
42 --bash <(_HASS_CLI_COMPLETE=bash_source $out/bin/hass-cli) \
43 --fish <(_HASS_CLI_COMPLETE=fish_source $out/bin/hass-cli) \
44 --zsh <(_HASS_CLI_COMPLETE=zsh_source $out/bin/hass-cli)
45 '';
46
47 nativeBuildInputs = [ installShellFiles ];
48
49 nativeCheckInputs = with python3.pkgs; [
50 pytestCheckHook
51 requests-mock
52 ];
53
54 pythonImportsCheck = [ "homeassistant_cli" ];
55
56 meta = {
57 description = "Command-line tool for Home Assistant";
58 mainProgram = "hass-cli";
59 homepage = "https://github.com/home-assistant-ecosystem/home-assistant-cli";
60 changelog = "https://github.com/home-assistant-ecosystem/home-assistant-cli/releases/tag/${version}";
61 license = lib.licenses.asl20;
62 teams = [ lib.teams.home-assistant ];
63 };
64}