nixpkgs/pkgs/servers/apache-kafka/default.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

81 lines
2.5 KiB
Nix
Raw Normal View History

{ lib, stdenv, fetchurl, jdk17_headless, jdk11_headless, makeWrapper, bash, coreutils, gnugrep, gnused, ps, nixosTests }:
let
versionMap = {
2024-08-15 16:14:16 +00:00
"3_8" = {
kafkaVersion = "3.8.0";
scalaVersion = "2.13";
sha256 = "sha256-4Cl8xv2wnvnZkFdRsl0rYpwXUo+GKbYFYe7/h84pCZw=";
jre = jdk17_headless;
nixosTest = nixosTests.kafka.kafka_3_8;
2024-08-15 16:14:16 +00:00
};
2024-06-13 14:01:49 +00:00
"3_7" = {
2024-07-18 16:48:06 +00:00
kafkaVersion = "3.7.1";
2024-06-13 14:01:49 +00:00
scalaVersion = "2.13";
2024-07-18 16:48:06 +00:00
sha256 = "sha256-YqyuShQ92YPcfrSATVdEugxQsZm1CPWZ7wAQIOJVj8k=";
2024-06-13 14:01:49 +00:00
jre = jdk17_headless;
nixosTest = nixosTests.kafka.kafka_3_7;
2024-06-13 14:01:49 +00:00
};
"3_6" = {
2024-06-13 14:03:21 +00:00
kafkaVersion = "3.6.2";
scalaVersion = "2.13";
2024-06-13 14:03:21 +00:00
sha256 = "sha256-wxfkf3cUHTFG6VY9nLodZIbIHmcLIR7OasRqn3Lkqqw=";
jre = jdk17_headless;
nixosTest = nixosTests.kafka.kafka_3_6;
};
};
2024-08-16 21:09:11 +00:00
build = versionInfo: stdenv.mkDerivation rec {
version = "${versionInfo.scalaVersion}-${versionInfo.kafkaVersion}";
pname = "apache-kafka";
src = fetchurl {
2024-08-16 21:09:11 +00:00
url = "mirror://apache/kafka/${versionInfo.kafkaVersion}/kafka_${version}.tgz";
inherit (versionInfo) sha256;
};
nativeBuildInputs = [ makeWrapper ];
2024-08-16 21:09:11 +00:00
buildInputs = [ versionInfo.jre bash gnugrep gnused coreutils ps ];
installPhase = ''
mkdir -p $out
cp -R config libs $out
mkdir -p $out/bin
cp bin/kafka* $out/bin
cp bin/connect* $out/bin
# allow us the specify logging directory using env
substituteInPlace $out/bin/kafka-run-class.sh \
--replace 'LOG_DIR="$base_dir/logs"' 'LOG_DIR="$KAFKA_LOG_DIR"'
substituteInPlace $out/bin/kafka-server-stop.sh \
--replace 'ps' '${ps}/bin/ps'
for p in $out/bin\/*.sh; do
wrapProgram $p \
2024-08-16 21:09:11 +00:00
--set JAVA_HOME "${versionInfo.jre}" \
--set KAFKA_LOG_DIR "/tmp/apache-kafka-logs" \
--prefix PATH : "${bash}/bin:${coreutils}/bin:${gnugrep}/bin:${gnused}/bin"
done
chmod +x $out/bin\/*
'';
passthru = {
2024-08-16 21:09:11 +00:00
inherit (versionInfo) jre; # Used by the NixOS module to select the supported JRE
tests.nixos = versionInfo.nixosTest;
};
2024-08-16 21:09:11 +00:00
meta = {
homepage = "https://kafka.apache.org";
description = "High-throughput distributed messaging system";
2024-08-16 21:09:11 +00:00
license = lib.licenses.asl20;
sourceProvenance = [ lib.sourceTypes.binaryBytecode ];
maintainers = [ lib.maintainers.ragge ];
platforms = lib.platforms.unix;
};
};
2024-08-16 21:09:11 +00:00
in lib.mapAttrs'
(majorVersion: versionInfo: lib.nameValuePair "apacheKafka_${majorVersion}" (build versionInfo))
versionMap