Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at fix-function-merge 74 lines 2.1 kB view raw
1{ lib 2, buildGoModule 3, fetchFromGitHub 4, installShellFiles 5}: 6 7buildGoModule rec { 8 pname = "apko"; 9 version = "0.14.1"; 10 11 src = fetchFromGitHub { 12 owner = "chainguard-dev"; 13 repo = pname; 14 rev = "v${version}"; 15 hash = "sha256-O1lU3b3dNmFcV0Dfkpw63Eu6AgLSLBi7MbF47OsjgL4="; 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 vendorHash = "sha256-shnVJ6TcqWxUu1Ib2ewaz2VK4mi1Rt3R0Cmof9ilDJ4="; 28 29 nativeBuildInputs = [ installShellFiles ]; 30 31 ldflags = [ 32 "-s" 33 "-w" 34 "-X sigs.k8s.io/release-utils/version.gitVersion=v${version}" 35 "-X sigs.k8s.io/release-utils/version.gitTreeState=clean" 36 ]; 37 38 # ldflags based on metadata from git and source 39 preBuild = '' 40 ldflags+=" -X sigs.k8s.io/release-utils/version.gitCommit=$(cat COMMIT)" 41 ldflags+=" -X sigs.k8s.io/release-utils/version.buildDate=$(cat SOURCE_DATE_EPOCH)" 42 ''; 43 44 checkFlags = [ 45 # fails to run on read-only filesystem 46 "-skip=(TestPublish|TestBuild|TestTarFS)" 47 ]; 48 49 postInstall = '' 50 installShellCompletion --cmd apko \ 51 --bash <($out/bin/apko completion bash) \ 52 --fish <($out/bin/apko completion fish) \ 53 --zsh <($out/bin/apko completion zsh) 54 ''; 55 56 doInstallCheck = true; 57 installCheckPhase = '' 58 runHook preInstallCheck 59 60 $out/bin/apko --help 61 $out/bin/apko version 2>&1 | grep "v${version}" 62 63 runHook postInstallCheck 64 ''; 65 66 meta = with lib; { 67 homepage = "https://apko.dev/"; 68 changelog = "https://github.com/chainguard-dev/apko/blob/main/NEWS.md"; 69 description = "Build OCI images using APK directly without Dockerfile"; 70 mainProgram = "apko"; 71 license = licenses.asl20; 72 maintainers = with maintainers; [ jk developer-guy ]; 73 }; 74}