nixpkgs/pkgs/tools/security/kubernetes-polaris/default.nix
stuebinm ff1a94e523 treewide: add meta.mainProgram to packages with a single binary
The nixpkgs-unstable channel's programs.sqlite was used to identify
packages producing exactly one binary, and these automatically added
to their package definitions wherever possible.
2024-03-19 03:14:51 +01:00

54 lines
1.3 KiB
Nix

{ lib, buildGoModule, fetchFromGitHub, installShellFiles, packr, ... }:
buildGoModule rec {
pname = "kubernetes-polaris";
version = "8.5.5";
src = fetchFromGitHub {
owner = "FairwindsOps";
repo = "polaris";
rev = version;
sha256 = "sha256-DKfCXtFrZgmR0jiXwCD1iuwx/8aNEjwZ/fCQNeRhSu4=";
};
vendorHash = "sha256-ZWetW+Xar4BXXlR0iG+O/NRqYk41x+PPVCGis2W2Nkk=";
nativeBuildInputs = [ installShellFiles ];
ldflags = [
"-s"
"-w"
"-X main.Version=${version}"
"-X main.Commit=${version}"
];
preBuild = ''
${packr}/bin/packr2 -v --ignore-imports
'';
postInstall = ''
installShellCompletion --cmd polaris \
--bash <($out/bin/polaris completion bash) \
--fish <($out/bin/polaris completion fish) \
--zsh <($out/bin/polaris completion zsh)
'';
doInstallCheck = true;
installCheckPhase = ''
runHook preInstallCheck
$out/bin/polaris help
$out/bin/polaris version | grep 'Polaris version:${version}'
runHook postInstallCheck
'';
meta = with lib; {
description = "Validate and remediate Kubernetes resources to ensure configuration best practices are followed";
mainProgram = "polaris";
homepage = "https://www.fairwinds.com/polaris";
license = with licenses; [ asl20 ];
maintainers = with maintainers; [ longer ];
};
}