nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 stdenv,
4 buildGoModule,
5 fetchFromGitHub,
6 installShellFiles,
7 testers,
8 ocm,
9}:
10
11buildGoModule rec {
12 pname = "ocm";
13 version = "1.0.10";
14
15 src = fetchFromGitHub {
16 owner = "openshift-online";
17 repo = "ocm-cli";
18 rev = "v${version}";
19 sha256 = "sha256-tY7THl1mv9XTL6KVO1/lvZpcNimk3M8pmCbXoH0oet0=";
20 };
21
22 vendorHash = "sha256-GOdRYVnFPS1ovFmU+9MEnwTNg1sa9/25AjzbcbBJrQ0=";
23
24 # Strip the final binary.
25 ldflags = [
26 "-s"
27 "-w"
28 ];
29
30 nativeBuildInputs = [ installShellFiles ];
31
32 # Tests expect the binary to be located in the root directory.
33 preCheck = ''
34 ln -s $GOPATH/bin/ocm ocm
35 '';
36
37 checkFlags = [
38 # Disable integration tests which require networking and gnupg which has issues in the sandbox
39 "-skip=^TestCLI$"
40 ];
41
42 postInstall = lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
43 installShellCompletion --cmd ocm \
44 --bash <($out/bin/ocm completion bash) \
45 --fish <($out/bin/ocm completion fish) \
46 --zsh <($out/bin/ocm completion zsh)
47 '';
48
49 passthru.tests.version = testers.testVersion {
50 package = ocm;
51 command = "ocm version";
52 };
53
54 meta = {
55 description = "CLI for the Red Hat OpenShift Cluster Manager";
56 mainProgram = "ocm";
57 license = lib.licenses.asl20;
58 homepage = "https://github.com/openshift-online/ocm-cli";
59 maintainers = with lib.maintainers; [
60 stehessel
61 jfchevrette
62 ];
63 };
64}