1{ stdenv, autoPatchelfHook, fetchurl, lib }:
2
3stdenv.mkDerivation rec {
4 pname = "confluent-cli";
5 version = "3.60.0";
6
7 # To get the latest version:
8 # curl -L https://cnfl.io/cli | sh -s -- -l | grep -v latest | sort -V | tail -n1
9 src = {
10 x86_64-linux = fetchurl {
11 url = "https://s3-us-west-2.amazonaws.com/confluent.cloud/confluent-cli/archives/${version}/confluent_${version}_linux_amd64.tar.gz";
12 hash = "sha256-GYA7T2yRcSNStvd9ZqI2iTJC3d6ymH9Dg5FVkIsM1f0=";
13 };
14 aarch64-linux = fetchurl {
15 url = "https://s3-us-west-2.amazonaws.com/confluent.cloud/confluent-cli/archives/${version}/confluent_${version}_linux_arm64.tar.gz";
16 hash = "sha256-BJJaZtRInKT6S0W22f96RCM8H18dIpOTP5lu357zh18=";
17 };
18 x86_64-darwin = fetchurl {
19 url = "https://s3-us-west-2.amazonaws.com/confluent.cloud/confluent-cli/archives/${version}/confluent_${version}_darwin_amd64.tar.gz";
20 hash = "sha256-94ur/FXxQWL4EOkEI1FSoWduRaMaY7DCNMiucpNC0B0=";
21 };
22 aarch64-darwin = fetchurl {
23 url = "https://s3-us-west-2.amazonaws.com/confluent.cloud/confluent-cli/archives/${version}/confluent_${version}_darwin_arm64.tar.gz";
24 hash = "sha256-aEIKSrO0/6dJCAyzwBH2ZDAmwvURugx6jTzaepbRvH8=";
25 };
26 }.${stdenv.hostPlatform.system} or (throw "Unsupported system: ${stdenv.hostPlatform.system}");
27
28 nativeBuildInputs = lib.optionals stdenv.hostPlatform.isLinux [ autoPatchelfHook ];
29
30 dontStrip = stdenv.isDarwin;
31
32 installPhase = ''
33 mkdir -p $out/{bin,share/doc/confluent-cli}
34 cp confluent $out/bin/
35 cp LICENSE $out/share/doc/confluent-cli/
36 cp -r legal $out/share/doc/confluent-cli/
37 '';
38
39 meta = with lib; {
40 description = "Confluent CLI";
41 homepage = "https://docs.confluent.io/confluent-cli/current/overview.html";
42 sourceProvenance = with sourceTypes; [ binaryNativeCode ];
43 license = licenses.unfree;
44 maintainers = with maintainers; [ rguevara84 autophagy ];
45
46 # TODO: There's support for i686 systems but I do not have any such system
47 # to build it locally on, it's also unfree so I cannot rely on ofborg to
48 # build it. Get the list of supported system by looking at the list of
49 # files in the S3 bucket:
50 #
51 # https://s3-us-west-2.amazonaws.com/confluent.cloud?prefix=confluent-cli/archives/1.25.0/&delimiter=/%27
52 platforms = platforms.unix;
53 };
54}