1{ lib
2, buildGoModule
3, fetchFromGitHub
4, git
5, stdenv
6, testers
7, manifest-tool
8}:
9
10buildGoModule rec {
11 pname = "manifest-tool";
12 version = "2.0.6";
13 gitCommit = "2ed9312726765567a84f2acc44a0c8a6e50f4b7a";
14 modRoot = "v2";
15
16 src = fetchFromGitHub {
17 owner = "estesp";
18 repo = "manifest-tool";
19 rev = "v${version}";
20 sha256 = "sha256-oopk++IdNF6msxOszT0fKxQABgWKbaQZ2aNH9chqWU0=";
21 leaveDotGit = true;
22 postFetch = ''
23 git -C $out rev-parse HEAD > $out/.git-revision
24 rm -rf $out/.git
25 '';
26 };
27
28 vendorHash = null;
29
30 nativeBuildInputs = [ git ];
31
32 preConfigure = ''
33 ldflags="-X main.gitCommit=$(cat .git-revision)"
34 '';
35
36 CGO_ENABLED = if stdenv.hostPlatform.isStatic then "0" else "1";
37 GO_EXTLINK_ENABLED = if stdenv.hostPlatform.isStatic then "0" else "1";
38 ldflags = lib.optionals stdenv.hostPlatform.isStatic [ "-w" "-extldflags" "-static" ];
39 tags = lib.optionals stdenv.hostPlatform.isStatic [ "netgo" ];
40
41 passthru.tests.version = testers.testVersion {
42 package = manifest-tool;
43 };
44
45 meta = with lib; {
46 description = "Command line tool to create and query container image manifest list/indexes";
47 homepage = "https://github.com/estesp/manifest-tool";
48 license = licenses.asl20;
49 maintainers = with maintainers; [ tricktron ];
50 };
51}