nixpkgs/pkgs/by-name/gi/gitleaks/package.nix

61 lines
1.5 KiB
Nix

{
lib,
stdenv,
buildGoModule,
fetchFromGitHub,
installShellFiles,
nix-update-script,
versionCheckHook,
git,
}:
buildGoModule rec {
pname = "gitleaks";
version = "8.27.1";
src = fetchFromGitHub {
owner = "zricethezav";
repo = "gitleaks";
tag = "v${version}";
hash = "sha256-Wsd/jyM16Ztkj4vNnui1qZE4v2ZBffdOVHJG4S+YLXU=";
};
vendorHash = "sha256-vd39TbooEdmYa6QZGEnYOmYU9p+9mV+SrLKVY+h/PEM=";
ldflags = [
"-s"
"-w"
"-X=github.com/zricethezav/gitleaks/v${lib.versions.major version}/cmd.Version=${version}"
];
nativeBuildInputs = [
installShellFiles
versionCheckHook
];
nativeCheckInputs = [ git ];
postInstall = lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
installShellCompletion --cmd ${pname} \
--bash <($out/bin/${pname} completion bash) \
--fish <($out/bin/${pname} completion fish) \
--zsh <($out/bin/${pname} completion zsh)
'';
doInstallCheck = true;
passthru.updateScript = nix-update-script { };
meta = {
description = "Scan git repos (or files) for secrets";
longDescription = ''
Gitleaks is a SAST tool for detecting hardcoded secrets like passwords,
API keys and tokens in git repos.
'';
homepage = "https://github.com/zricethezav/gitleaks";
changelog = "https://github.com/zricethezav/gitleaks/releases/tag/v${version}";
license = with lib.licenses; [ mit ];
maintainers = with lib.maintainers; [ fab ];
mainProgram = "gitleaks";
};
}