1{ lib
2, buildGoModule
3, fetchFromGitHub
4, git
5, installShellFiles
6}:
7
8buildGoModule rec {
9 pname = "ko";
10 version = "0.12.0";
11
12 src = fetchFromGitHub {
13 owner = "ko-build";
14 repo = pname;
15 rev = "v${version}";
16 sha256 = "sha256-hhPV40e5wB2/VcdigqgjffDW4X1ZDddXTZiCUBijtHQ=";
17 };
18 vendorSha256 = null;
19
20 nativeBuildInputs = [ installShellFiles ];
21
22 # Pin so that we don't build the several other development tools
23 subPackages = ".";
24
25 ldflags = [ "-s" "-w" "-X github.com/google/ko/pkg/commands.Version=${version}" ];
26
27 checkInputs = [ git ];
28 preCheck = ''
29 # Feed in all the tests for testing
30 # This is because subPackages above limits what is built to just what we
31 # want but also limits the tests
32 getGoDirs() {
33 go list ./...
34 }
35
36 # resolves some complaints from ko
37 export GOROOT="$(go env GOROOT)"
38 git init
39
40 # ko tests will fail if any of those env are set, as ko tries
41 # to make sure it can build and target multiple GOOS/GOARCH
42 unset GOOS GOARCH GOARM
43 '';
44
45 postInstall = ''
46 installShellCompletion --cmd ko \
47 --bash <($out/bin/ko completion bash) \
48 --fish <($out/bin/ko completion fish) \
49 --zsh <($out/bin/ko completion zsh)
50 '';
51
52 meta = with lib; {
53 homepage = "https://github.com/ko-build/ko";
54 changelog = "https://github.com/ko-build/ko/releases/tag/v${version}";
55 description = "Build and deploy Go applications on Kubernetes";
56 longDescription = ''
57 ko is a simple, fast container image builder for Go applications.
58 It's ideal for use cases where your image contains a single Go application without any/many dependencies on the OS base image (e.g. no cgo, no OS package dependencies).
59 ko builds images by effectively executing go build on your local machine, and as such doesn't require docker to be installed. This can make it a good fit for lightweight CI/CD use cases.
60 ko also includes support for simple YAML templating which makes it a powerful tool for Kubernetes applications.
61 '';
62 license = licenses.asl20;
63 maintainers = with maintainers; [ nickcao jk vdemeester ];
64 };
65}