From c7b8a912d0e0075094c6fb66f8879c9b42a76066 Mon Sep 17 00:00:00 2001 From: Mathieu Rene Date: Mon, 29 Jul 2024 20:51:32 -0400 Subject: [PATCH] home-assistant-cli: fix shell completions --- pkgs/servers/home-assistant/cli.nix | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/pkgs/servers/home-assistant/cli.nix b/pkgs/servers/home-assistant/cli.nix index d3c8348e3034..d8839e155d56 100644 --- a/pkgs/servers/home-assistant/cli.nix +++ b/pkgs/servers/home-assistant/cli.nix @@ -1,7 +1,9 @@ { lib, + stdenv, fetchFromGitHub, python3, + installShellFiles, }: python3.pkgs.buildPythonApplication rec { @@ -35,15 +37,14 @@ python3.pkgs.buildPythonApplication rec { tabulate ]; - # TODO: Completion needs to be adapted after support for latest click was added - # $ source <(_HASS_CLI_COMPLETE=bash_source hass-cli) # for bash - # $ source <(_HASS_CLI_COMPLETE=zsh_source hass-cli) # for zsh - # $ eval (_HASS_CLI_COMPLETE=fish_source hass-cli) # for fish - #postInstall = '' - # mkdir -p "$out/share/bash-completion/completions" "$out/share/zsh/site-functions" - # $out/bin/hass-cli completion bash > "$out/share/bash-completion/completions/hass-cli" - # $out/bin/hass-cli completion zsh > "$out/share/zsh/site-functions/_hass-cli" - #''; + postInstall = lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) '' + installShellCompletion --cmd hass-cli \ + --bash <(_HASS_CLI_COMPLETE=bash_source $out/bin/hass-cli) \ + --fish <(_HASS_CLI_COMPLETE=fish_source $out/bin/hass-cli) \ + --zsh <(_HASS_CLI_COMPLETE=zsh_source $out/bin/hass-cli) + ''; + + nativeBuildInputs = [ installShellFiles ]; nativeCheckInputs = with python3.pkgs; [ pytestCheckHook