-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkafka.nix
47 lines (42 loc) · 1.26 KB
/
kafka.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
{ pkgs }: rec {
apacheKafka = pkgs.apacheKafka.overrideAttrs (super: rec {
pname = "apache-kafka";
version = "2.13-3.7.0";
src = pkgs.fetchurl {
url =
"https://downloads.apache.org/kafka/${version}/kafka_${version}.tgz";
sha256 = "sha256-ZfJuWTe7t23+eN+0FnMN+n4zeLJ+E/0eIE8aEJm/r5w=";
};
});
packages = rec {
kafka = apacheKafka;
serverProperties = pkgs.stdenv.mkDerivation {
name = "server.properties";
src = ./config;
buildInputs = [ pkgs.dhall ];
buildPhase = ''
${pkgs.dhall}/bin/dhall text --file kraft.dhall > server.properties
'';
installPhase = ''
cp -v server.properties $out
'';
};
};
shellDeps = with pkgs; [ apacheKafka kafkactl zulu ];
cmd = with packages; {
kafkup = let
storage = "${apacheKafka}/bin/kafka-storage.sh";
start = "${apacheKafka}/bin/kafka-server-start.sh";
in ''
if [ -z "$KAFKA_CLUSTER_ID" ]; then
export KAFKA_CLUSTER_ID=$(${storage} random-uuid)
rm -rfv /tmp/kraft-combined-logs
fi
${storage} format -g -t "$KAFKA_CLUSTER_ID" -c ${serverProperties}
${start} -daemon ${serverProperties}
'';
kafkout = ''
${apacheKafka}/bin/kafka-server-stop.sh
'';
};
}