2021-10-08 13:04:08 +02:00
|
|
|
{ lib, buildGoModule, fetchFromGitHub, fetchgit, installShellFiles }:
|
2021-08-07 10:03:11 +02:00
|
|
|
|
|
|
|
buildGoModule rec {
|
|
|
|
pname = "scorecard";
|
2022-05-23 19:55:17 +02:00
|
|
|
version = "4.3.0";
|
2021-08-07 10:03:11 +02:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "ossf";
|
|
|
|
repo = pname;
|
|
|
|
rev = "v${version}";
|
2022-05-23 19:55:17 +02:00
|
|
|
sha256 = "sha256-+aocaMnEDqaOjiCPmAxhf1tiqMN6DKo64N0ARMmY71E=";
|
2021-10-08 13:04:08 +02:00
|
|
|
# populate values otherwise taken care of by goreleaser,
|
|
|
|
# unfortunately these 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-05-09 12:28:25 +02: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
|
2021-10-08 13:04:08 +02:00
|
|
|
find "$out" -name .git -print0 | xargs -0 rm -rf
|
|
|
|
'';
|
2021-08-07 10:03:11 +02:00
|
|
|
};
|
2022-05-23 19:55:17 +02:00
|
|
|
vendorSha256 = "sha256-0VEo08lGVQ3ROdqFrpNVgdtfaKqNY4hhjZ0i3U52P4M=";
|
2021-08-07 10:03:11 +02:00
|
|
|
|
|
|
|
nativeBuildInputs = [ installShellFiles ];
|
|
|
|
|
2021-09-29 14:21:24 +02:00
|
|
|
subPackages = [ "." ];
|
|
|
|
|
|
|
|
ldflags = [
|
|
|
|
"-s"
|
|
|
|
"-w"
|
2022-05-09 12:28:25 +02:00
|
|
|
"-X sigs.k8s.io/release-utils/version.gitVersion=v${version}"
|
|
|
|
"-X sigs.k8s.io/release-utils/version.gitTreeState=clean"
|
2021-09-29 14:21:24 +02:00
|
|
|
];
|
|
|
|
|
2022-05-09 12:28:25 +02:00
|
|
|
# ldflags based on metadata from git and source
|
|
|
|
preBuild = ''
|
|
|
|
ldflags+=" -X sigs.k8s.io/release-utils/version.gitCommit=$(cat COMMIT)"
|
|
|
|
ldflags+=" -X sigs.k8s.io/release-utils/version.buildDate=$(cat SOURCE_DATE_EPOCH)"
|
|
|
|
'';
|
|
|
|
|
2021-08-07 10:03:11 +02:00
|
|
|
preCheck = ''
|
|
|
|
# Feed in all but the e2e tests for testing
|
|
|
|
# This is because subPackages above limits what is built to just what we
|
|
|
|
# want but also limits the tests
|
|
|
|
getGoDirs() {
|
|
|
|
go list ./... | grep -v e2e
|
|
|
|
}
|
2022-02-23 12:57:54 +01:00
|
|
|
# Ensure other e2e tests that have escaped the e2e dir dont run
|
|
|
|
export SKIP_GINKGO=1
|
2021-08-07 10:03:11 +02:00
|
|
|
'';
|
|
|
|
|
|
|
|
postInstall = ''
|
|
|
|
installShellCompletion --cmd scorecard \
|
|
|
|
--bash <($out/bin/scorecard completion bash) \
|
|
|
|
--fish <($out/bin/scorecard completion fish) \
|
|
|
|
--zsh <($out/bin/scorecard completion zsh)
|
|
|
|
'';
|
|
|
|
|
|
|
|
doInstallCheck = true;
|
|
|
|
installCheckPhase = ''
|
|
|
|
runHook preInstallCheck
|
|
|
|
$out/bin/scorecard --help
|
2022-05-09 12:28:25 +02:00
|
|
|
# $out/bin/scorecard version 2>&1 | grep "v${version}"
|
2021-08-07 10:03:11 +02:00
|
|
|
runHook postInstallCheck
|
|
|
|
'';
|
|
|
|
|
|
|
|
meta = with lib; {
|
|
|
|
homepage = "https://github.com/ossf/scorecard";
|
|
|
|
changelog = "https://github.com/ossf/scorecard/releases/tag/v${version}";
|
|
|
|
description = "Security health metrics for Open Source";
|
|
|
|
license = licenses.asl20;
|
|
|
|
maintainers = with maintainers; [ jk ];
|
|
|
|
};
|
|
|
|
}
|