{ lib, stdenv, buildGoModule, fetchFromGitHub, installShellFiles, nix-update-script, versionCheckHook, git, }: buildGoModule rec { pname = "gitleaks"; version = "8.28.0"; src = fetchFromGitHub { owner = "zricethezav"; repo = "gitleaks"; tag = "v${version}"; hash = "sha256-smh3Ge278lYVEcs6r1F43daexgjgddy1HKhU5E4CBYM="; }; vendorHash = "sha256-dd9sHt5t0s4Vff1rOwQY1OC+0FIw0SDt/cwJN+IL5D8="; 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"; }; }