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