nixpkgs/pkgs/by-name/sy/syft/package.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

92 lines
2.4 KiB
Nix
Raw Normal View History

2024-04-04 22:45:57 +00:00
{
lib,
buildGoModule,
fetchFromGitHub,
installShellFiles,
2024-04-04 22:45:05 +00:00
}:
2022-01-21 12:59:17 +00:00
buildGoModule rec {
pname = "syft";
2024-04-27 02:48:45 +00:00
version = "1.3.0";
2022-01-21 12:59:17 +00:00
src = fetchFromGitHub {
owner = "anchore";
2024-04-04 22:45:05 +00:00
repo = "syft";
rev = "refs/tags/v${version}";
2024-04-27 02:48:45 +00:00
hash = "sha256-9U1PBLAj4oWKyUWrBbrlqM4MldYlYN20W5VAWxQ9nq4=";
2022-01-21 12:59:17 +00:00
# populate values that require us to use git. By doing this in postFetch we
# can delete .git afterwards and maintain better reproducibility of the src.
leaveDotGit = true;
postFetch = ''
cd "$out"
2022-03-17 18:30:37 +00:00
git rev-parse HEAD > $out/COMMIT
# 0000-00-00T00:00:00Z
date -u -d "@$(git log -1 --pretty=%ct)" "+%Y-%m-%dT%H:%M:%SZ" > $out/SOURCE_DATE_EPOCH
2022-01-21 12:59:17 +00:00
find "$out" -name .git -print0 | xargs -0 rm -rf
'';
};
2022-11-03 10:08:48 +00:00
# hash mismatch with darwin
proxyVendor = true;
2024-04-04 22:45:05 +00:00
2024-04-27 02:48:45 +00:00
vendorHash = "sha256-UuQpO6iZN3ITQLj4xccEmxpmgfKSTigImlTPSvPgFyM=";
2022-01-21 12:59:17 +00:00
nativeBuildInputs = [ installShellFiles ];
2022-05-17 08:23:21 +00:00
subPackages = [ "cmd/syft" ];
2022-01-21 12:59:17 +00:00
ldflags = [
"-s"
"-w"
2024-04-04 22:45:05 +00:00
"-X=main.version=${version}"
"-X=main.gitDescription=v${version}"
"-X=main.gitTreeState=clean"
2022-01-21 12:59:17 +00:00
];
2022-03-17 18:30:37 +00:00
preBuild = ''
2023-09-14 13:10:48 +00:00
ldflags+=" -X main.gitCommit=$(cat COMMIT)"
ldflags+=" -X main.buildDate=$(cat SOURCE_DATE_EPOCH)"
2022-03-17 18:30:37 +00:00
'';
2022-01-21 12:59:17 +00:00
# tests require a running docker instance
doCheck = false;
postInstall = ''
# avoid update checks when generating completions
export SYFT_CHECK_FOR_APP_UPDATE=false
installShellCompletion --cmd syft \
--bash <($out/bin/syft completion bash) \
--fish <($out/bin/syft completion fish) \
--zsh <($out/bin/syft completion zsh)
'';
2022-05-17 08:23:21 +00:00
doInstallCheck = true;
installCheckPhase = ''
runHook preInstallCheck
export SYFT_CHECK_FOR_APP_UPDATE=false
$out/bin/syft --help
$out/bin/syft version | grep "${version}"
runHook postInstallCheck
'';
2022-01-21 12:59:17 +00:00
meta = with lib; {
2024-04-04 22:45:05 +00:00
description = "CLI tool and library for generating a Software Bill of Materials from container images and filesystems";
2022-01-21 12:59:17 +00:00
homepage = "https://github.com/anchore/syft";
changelog = "https://github.com/anchore/syft/releases/tag/v${version}";
longDescription = ''
A CLI tool and Go library for generating a Software Bill of Materials
(SBOM) from container images and filesystems. Exceptional for
vulnerability detection when used with a scanner tool like Grype.
'';
license = with licenses; [ asl20 ];
2024-04-04 22:45:57 +00:00
maintainers = with maintainers; [
developer-guy
jk
kashw2
];
2024-02-11 02:19:15 +00:00
mainProgram = "syft";
2022-01-21 12:59:17 +00:00
};
}