1{
2 lib,
3 stdenv,
4 fetchurl,
5 autoPatchelfHook,
6}:
7
8stdenv.mkDerivation (finalAttrs: {
9 pname = "confluent-cli";
10 version = "4.32.0";
11
12 # To get the latest version:
13 # curl -L https://cnfl.io/cli | sh -s -- -l | grep -v latest | sort -V | tail -n1
14 src =
15 let
16 selectSystem =
17 attrs:
18 attrs.${stdenv.hostPlatform.system} or (throw "Unsupported system: ${stdenv.hostPlatform.system}");
19 system = selectSystem {
20 x86_64-linux = "linux_amd64";
21 aarch64-linux = "linux_arm64";
22 x86_64-darwin = "darwin_amd64";
23 aarch64-darwin = "darwin_arm64";
24 };
25 in
26 fetchurl {
27 url = "https://s3-us-west-2.amazonaws.com/confluent.cloud/confluent-cli/archives/${finalAttrs.version}/confluent_${finalAttrs.version}_${system}.tar.gz";
28 hash = selectSystem {
29 x86_64-linux = "sha256-T2rMFkcbohRicRsZHdNMJtHEJvDNJq5yJn25gJXaMfw=";
30 aarch64-linux = "sha256-KpkohZMPQqnggftBGugLmz4f8UX4MkrvV90flBRdy18=";
31 x86_64-darwin = "sha256-/MUEzLkycQO1jTMAPhGzhT15RpO/Mzexj0wKbr2bSXk=";
32 aarch64-darwin = "sha256-Qqyw9TgGlj9fAFJknsvyohUQ3SleGGv/gvkCPkmFAuY=";
33 };
34 };
35
36 nativeBuildInputs = lib.optionals stdenv.hostPlatform.isLinux [ autoPatchelfHook ];
37
38 dontStrip = stdenv.hostPlatform.isDarwin;
39
40 installPhase = ''
41 runHook preInstall
42
43 mkdir -p $out/{bin,share/doc/confluent-cli}
44 cp confluent $out/bin/
45 cp LICENSE $out/share/doc/confluent-cli/
46 cp -r legal $out/share/doc/confluent-cli/
47
48 runHook postInstall
49 '';
50
51 passthru.updateScript = ./update.sh;
52
53 meta = {
54 description = "Confluent CLI";
55 homepage = "https://docs.confluent.io/confluent-cli/current/overview.html";
56 sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ];
57 license = lib.licenses.unfreeRedistributable;
58 maintainers = with lib.maintainers; [
59 rguevara84
60 autophagy
61 ];
62 # TODO: There's support for i686 systems but I do not have any such system
63 # to build it locally on, it's also unfree so I cannot rely on ofborg to
64 # build it. Get the list of supported system by looking at the list of
65 # files in the S3 bucket:
66 #
67 # https://s3-us-west-2.amazonaws.com/confluent.cloud?prefix=confluent-cli/archives/1.25.0/&delimiter=/%27
68 platforms = lib.platforms.unix;
69 };
70})