traefik: add djds as maintainer (#377217)
[NixPkgs.git] / pkgs / by-name / st / starboard / package.nix
blob9dd824c1d55341e619e9683decf13dcee4f54152
2   lib,
3   buildGoModule,
4   fetchFromGitHub,
5   installShellFiles,
6 }:
8 buildGoModule rec {
9   pname = "starboard";
10   version = "0.15.23";
12   src = fetchFromGitHub {
13     owner = "aquasecurity";
14     repo = pname;
15     rev = "v${version}";
16     hash = "sha256-eBAOrIGlAJ7r9UviCZUELG5p3k08OqvFUGZ8Ovnxsis=";
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-meZMuo+3Qv95TYYDslMpdfFG0KAbY/tufjcT7HgZB2c=";
30   nativeBuildInputs = [ installShellFiles ];
32   subPackages = [ "cmd/starboard" ];
34   ldflags = [
35     "-s"
36     "-w"
37     "-X main.version=v${version}"
38   ];
40   # ldflags based on metadata from git and source
41   preBuild = ''
42     ldflags+=" -X main.gitCommit=$(cat COMMIT)"
43     ldflags+=" -X main.buildDate=$(cat SOURCE_DATE_EPOCH)"
44   '';
46   preCheck = ''
47     # Remove test that requires networking
48     rm pkg/plugin/aqua/client/client_integration_test.go
50     # Feed in all but the integration tests for testing
51     # This is because subPackages above limits what is built to just what we
52     # want but also limits the tests
53     getGoDirs() {
54       go list ./... | grep -v itest
55     }
56   '';
58   postInstall = ''
59     installShellCompletion --cmd starboard \
60       --bash <($out/bin/starboard completion bash) \
61       --fish <($out/bin/starboard completion fish) \
62       --zsh <($out/bin/starboard completion zsh)
63   '';
65   doInstallCheck = true;
66   installCheckPhase = ''
67     runHook preInstallCheck
68     $out/bin/starboard --help
69     $out/bin/starboard version | grep "v${version}"
70     runHook postInstallCheck
71   '';
73   meta = with lib; {
74     homepage = "https://github.com/aquasecurity/starboard";
75     changelog = "https://github.com/aquasecurity/starboard/releases/tag/v${version}";
76     description = "Kubernetes-native security tool kit";
77     mainProgram = "starboard";
78     longDescription = ''
79       Starboard integrates security tools into the Kubernetes environment, so
80       that users can find and view the risks that relate to different resources
81       in a Kubernetes-native way. Starboard provides custom security resources
82       definitions and a Go module to work with a range of existing security
83       tools, as well as a kubectl-compatible command-line tool and an Octant
84       plug-in that make security reports available through familiar Kubernetes
85       tools.
86     '';
87     license = licenses.asl20;
88     maintainers = with maintainers; [ jk ];
89   };