Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at flake-libs 89 lines 2.4 kB view raw
1{ 2 lib, 3 buildGoModule, 4 fetchFromGitHub, 5 installShellFiles, 6}: 7 8buildGoModule rec { 9 pname = "apko"; 10 version = "0.27.2"; 11 12 src = fetchFromGitHub { 13 owner = "chainguard-dev"; 14 repo = pname; 15 tag = "v${version}"; 16 hash = "sha256-OcEDXbAiBN8x0XilkkAfCxIb5PksPxZ00xlfmF829EY="; 17 # populate values that require us to use git. By doing this in postFetch we 18 # can delete .git afterwards and maintain better reproducibility of the src. 19 leaveDotGit = true; 20 postFetch = '' 21 cd "$out" 22 git rev-parse HEAD > $out/COMMIT 23 # '0000-00-00T00:00:00Z' 24 date -u -d "@$(git log -1 --pretty=%ct)" "+'%Y-%m-%dT%H:%M:%SZ'" > $out/SOURCE_DATE_EPOCH 25 find "$out" -name .git -print0 | xargs -0 rm -rf 26 ''; 27 }; 28 vendorHash = "sha256-dc2keDzWeyyNOAxYehTAGXacP+U0wD68PqzXij8sh2I="; 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 preCheck = '' 46 # some tests require a writable HOME 47 export HOME=$(mktemp -d) 48 49 # some test data include SOURCE_DATE_EPOCH (which is different from our default) 50 # and the default version info which we get by unsetting our ldflags 51 export SOURCE_DATE_EPOCH=0 52 ldflags= 53 ''; 54 55 checkFlags = [ 56 # requires networking (apk.chainreg.biz) 57 "-skip=TestInitDB_ChainguardDiscovery" 58 ]; 59 60 postInstall = '' 61 installShellCompletion --cmd apko \ 62 --bash <($out/bin/apko completion bash) \ 63 --fish <($out/bin/apko completion fish) \ 64 --zsh <($out/bin/apko completion zsh) 65 ''; 66 67 doInstallCheck = true; 68 installCheckPhase = '' 69 runHook preInstallCheck 70 71 $out/bin/apko --help 72 $out/bin/apko version 2>&1 | grep "v${version}" 73 74 runHook postInstallCheck 75 ''; 76 77 meta = with lib; { 78 homepage = "https://apko.dev/"; 79 changelog = "https://github.com/chainguard-dev/apko/blob/main/NEWS.md"; 80 description = "Build OCI images using APK directly without Dockerfile"; 81 mainProgram = "apko"; 82 license = licenses.asl20; 83 maintainers = with maintainers; [ 84 jk 85 developer-guy 86 emilylange 87 ]; 88 }; 89}