depot/third_party/nixpkgs/pkgs/by-name/st/stern/package.nix

61 lines
1.3 KiB
Nix

{
buildGoModule,
buildPackages,
fetchFromGitHub,
installShellFiles,
lib,
stdenv,
stern,
testers,
}:
buildGoModule rec {
pname = "stern";
version = "1.31.0";
src = fetchFromGitHub {
owner = "stern";
repo = "stern";
rev = "v${version}";
hash = "sha256-1jwjd9enO2rQnC+04brzfJKSutnkWLMPyZD0wAqHBfg=";
};
vendorHash = "sha256-IBOkx+y7EFQeQ0sumXiVRqKqHts4SOxB138Uz644cnc=";
subPackages = [ "." ];
ldflags = [
"-s"
"-w"
"-X github.com/stern/stern/cmd.version=${version}"
];
nativeBuildInputs = [ installShellFiles ];
postInstall =
let
stern = if stdenv.buildPlatform.canExecute stdenv.hostPlatform then "$out" else buildPackages.stern;
in
''
for shell in bash zsh fish; do
${stern}/bin/stern --completion $shell > stern.$shell
installShellCompletion stern.$shell
done
'';
passthru.tests.version = testers.testVersion {
package = stern;
};
meta = {
description = "Multi pod and container log tailing for Kubernetes";
changelog = "https://github.com/stern/stern/releases/tag/v${version}";
homepage = "https://github.com/stern/stern";
license = lib.licenses.asl20;
mainProgram = "stern";
maintainers = with lib.maintainers; [
mbode
preisschild
];
};
}