Merge pull request #263801 from twz123/diffoci-version

diffoci: Add version literal and shell completions
This commit is contained in:
Emily
2024-01-03 18:47:50 +01:00
committed by GitHub
+21 -1
View File
@@ -1,6 +1,9 @@
{ lib
, stdenv
, buildPackages
, buildGoModule
, fetchFromGitHub
, installShellFiles
}:
buildGoModule rec {
@@ -16,7 +19,24 @@ buildGoModule rec {
vendorHash = "sha256-4C35LBxSm6EkcOznQY1hT2vX9bwFfps/q76VqqPKBfI=";
ldflags = [ "-s" "-w" ];
ldflags = [
"-s"
"-w"
"-X=github.com/reproducible-containers/diffoci/cmd/diffoci/version.Version=v${version}"
];
nativeBuildInputs = [ installShellFiles ];
postInstall =
let
diffoci = if stdenv.buildPlatform.canExecute stdenv.hostPlatform then placeholder "out" else buildPackages.diffoci;
in
''
installShellCompletion --cmd trivy \
--bash <(${diffoci}/bin/diffoci completion bash) \
--fish <(${diffoci}/bin/diffoci completion fish) \
--zsh <(${diffoci}/bin/diffoci completion zsh)
'';
meta = with lib; {
description = "Diff for Docker and OCI container images";