at 23.11-beta 69 lines 2.0 kB view raw
1{ lib 2, buildGoModule 3, fetchFromGitHub 4, installShellFiles 5}: 6 7buildGoModule rec { 8 pname = "bom"; 9 version = "0.5.1"; 10 11 src = fetchFromGitHub { 12 owner = "kubernetes-sigs"; 13 repo = pname; 14 rev = "v${version}"; 15 sha256 = "sha256-/a+0kQn2m5JFxhlgs1pUeyWwwqVFrRbYCyUfcLsNGz8="; 16 # populate values that require us to use git. By doing this in postFetch we 17 # can delete .git afterwards and maintain better reproducibility of the src. 18 leaveDotGit = true; 19 postFetch = '' 20 cd "$out" 21 git rev-parse HEAD > $out/COMMIT 22 # '0000-00-00T00:00:00Z' 23 date -u -d "@$(git log -1 --pretty=%ct)" "+'%Y-%m-%dT%H:%M:%SZ'" > $out/SOURCE_DATE_EPOCH 24 find "$out" -name .git -print0 | xargs -0 rm -rf 25 ''; 26 }; 27 28 vendorHash = "sha256-+dFHVIE3YFQVgYwEDtUWJAfHSnBZox8qejJtuIMPS2I="; 29 30 nativeBuildInputs = [ installShellFiles ]; 31 32 ldflags = [ 33 "-s" 34 "-w" 35 "-X sigs.k8s.io/release-utils/version.gitVersion=v${version}" 36 "-X sigs.k8s.io/release-utils/version.gitTreeState=clean" 37 ]; 38 39 # ldflags based on metadata from git and source 40 preBuild = '' 41 ldflags+=" -X sigs.k8s.io/release-utils/version.gitCommit=$(cat COMMIT)" 42 ldflags+=" -X sigs.k8s.io/release-utils/version.buildDate=$(cat SOURCE_DATE_EPOCH)" 43 ''; 44 45 postInstall = '' 46 installShellCompletion --cmd bom \ 47 --bash <($out/bin/bom completion bash) \ 48 --fish <($out/bin/bom completion fish) \ 49 --zsh <($out/bin/bom completion zsh) 50 ''; 51 52 doInstallCheck = true; 53 installCheckPhase = '' 54 runHook preInstallCheck 55 $out/bin/bom --help 56 $out/bin/bom version 2>&1 | grep "v${version}" 57 runHook postInstallCheck 58 ''; 59 60 doCheck = false; 61 62 meta = with lib; { 63 homepage = "https://github.com/kubernetes-sigs/bom"; 64 changelog = "https://github.com/kubernetes-sigs/bom/releases/tag/v${version}"; 65 description = "A utility to generate SPDX-compliant Bill of Materials manifests"; 66 license = licenses.asl20; 67 maintainers = with maintainers; [ developer-guy ]; 68 }; 69}