2023-08-04 22:07:22 +00:00
|
|
|
{ lib, buildGoModule, fetchFromGitHub, installShellFiles }:
|
2022-01-25 03:21:06 +00:00
|
|
|
|
|
|
|
buildGoModule rec {
|
|
|
|
pname = "syft";
|
2024-01-02 11:29:13 +00:00
|
|
|
version = "0.99.0";
|
2022-01-25 03:21:06 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "anchore";
|
|
|
|
repo = pname;
|
|
|
|
rev = "v${version}";
|
2024-01-02 11:29:13 +00:00
|
|
|
hash = "sha256-1Fw/1OVSKW+sIfVD4rodtTwu7JUhIsLEvIpYP49SqKQ=";
|
2022-01-25 03:21:06 +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-30 09:31:56 +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-25 03:21:06 +00:00
|
|
|
find "$out" -name .git -print0 | xargs -0 rm -rf
|
|
|
|
'';
|
|
|
|
};
|
2022-11-04 12:27:35 +00:00
|
|
|
# hash mismatch with darwin
|
|
|
|
proxyVendor = true;
|
2024-01-02 11:29:13 +00:00
|
|
|
vendorHash = "sha256-y6tw/umiEgwdoafa/CTg78naMWvr+DBOtXT/rMs1agQ=";
|
2022-01-25 03:21:06 +00:00
|
|
|
|
|
|
|
nativeBuildInputs = [ installShellFiles ];
|
|
|
|
|
2022-05-18 14:49:53 +00:00
|
|
|
subPackages = [ "cmd/syft" ];
|
2022-01-25 03:21:06 +00:00
|
|
|
|
|
|
|
ldflags = [
|
|
|
|
"-s"
|
|
|
|
"-w"
|
2023-10-09 19:29:22 +00:00
|
|
|
"-X main.version=${version}"
|
|
|
|
"-X main.gitDescription=v${version}"
|
|
|
|
"-X main.gitTreeState=clean"
|
2022-01-25 03:21:06 +00:00
|
|
|
];
|
|
|
|
|
2022-03-30 09:31:56 +00:00
|
|
|
preBuild = ''
|
2023-10-09 19:29:22 +00:00
|
|
|
ldflags+=" -X main.gitCommit=$(cat COMMIT)"
|
|
|
|
ldflags+=" -X main.buildDate=$(cat SOURCE_DATE_EPOCH)"
|
2022-03-30 09:31:56 +00:00
|
|
|
'';
|
|
|
|
|
2022-01-25 03:21:06 +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-18 14:49:53 +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-25 03:21:06 +00:00
|
|
|
meta = with lib; {
|
|
|
|
homepage = "https://github.com/anchore/syft";
|
|
|
|
changelog = "https://github.com/anchore/syft/releases/tag/v${version}";
|
|
|
|
description = "CLI tool and library for generating a Software Bill of Materials from container images and filesystems";
|
|
|
|
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 ];
|
2023-08-22 20:05:09 +00:00
|
|
|
maintainers = with maintainers; [ jk developer-guy kashw2 ];
|
2022-01-25 03:21:06 +00:00
|
|
|
};
|
|
|
|
}
|