trivy: add shell completions

This commit is contained in:
Tom Wieczorek 2023-11-23 16:05:54 +01:00
parent c757e9bd77
commit b297cddb05
No known key found for this signature in database
GPG Key ID: FE33A2282371E831

View File

@ -1,6 +1,9 @@
{ lib
, stdenv
, buildPackages
, buildGoModule
, fetchFromGitHub
, installShellFiles
, testers
, trivy
}:
@ -29,9 +32,22 @@ buildGoModule rec {
"-X=github.com/aquasecurity/trivy/pkg/version.ver=v${version}"
];
nativeBuildInputs = [ installShellFiles ];
# Tests require network access
doCheck = false;
postInstall =
let
trivy = if stdenv.buildPlatform.canExecute stdenv.hostPlatform then placeholder "out" else buildPackages.trivy;
in
''
installShellCompletion --cmd trivy \
--bash <(${trivy}/bin/trivy completion bash) \
--fish <(${trivy}/bin/trivy completion fish) \
--zsh <(${trivy}/bin/trivy completion zsh)
'';
doInstallCheck = true;
passthru.tests.version = testers.testVersion {