apacheKafka: callPackages

To please the by-name gods :-)
This commit is contained in:
Sarah Brofeldt 2024-02-09 07:36:46 +01:00
parent 27a384a0ab
commit ff5e9d2cd8
2 changed files with 56 additions and 55 deletions

View File

@ -1,71 +1,70 @@
{ lib, stdenv, fetchurl, jdk17_headless, jdk11_headless, makeWrapper, bash, coreutils, gnugrep, gnused, ps,
majorVersion ? "1.0" }:
{ lib, stdenv, fetchurl, jdk17_headless, jdk11_headless, makeWrapper, bash, coreutils, gnugrep, gnused, ps }:
let
versionMap = {
"3.6" = {
"3_6" = {
kafkaVersion = "3.6.1";
scalaVersion = "2.13";
sha256 = "sha256-49tWjH+PzMf5gep7CUQmiukxBZLHPuDrV56/2/zy08o=";
jre = jdk17_headless;
};
"3.5" = {
"3_5" = {
kafkaVersion = "3.5.2";
scalaVersion = "2.13";
sha256 = "sha256-vBryxHFLPFB8qpFFkMKOeBX2Zxp0MkvEd+HIOohUg8M=";
jre = jdk17_headless;
};
};
in
with versionMap.${majorVersion};
build = versionInfo: with versionInfo; stdenv.mkDerivation rec {
version = "${scalaVersion}-${kafkaVersion}";
pname = "apache-kafka";
stdenv.mkDerivation rec {
version = "${scalaVersion}-${kafkaVersion}";
pname = "apache-kafka";
src = fetchurl {
url = "mirror://apache/kafka/${kafkaVersion}/kafka_${version}.tgz";
inherit sha256;
};
src = fetchurl {
url = "mirror://apache/kafka/${kafkaVersion}/kafka_${version}.tgz";
inherit sha256;
nativeBuildInputs = [ makeWrapper ];
buildInputs = [ 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 \
--set JAVA_HOME "${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 = {
inherit jre; # Used by the NixOS module to select the supported jre
};
meta = with lib; {
homepage = "https://kafka.apache.org";
description = "High-throughput distributed messaging system";
license = licenses.asl20;
sourceProvenance = with sourceTypes; [ binaryBytecode ];
maintainers = [ maintainers.ragge ];
platforms = platforms.unix;
};
};
nativeBuildInputs = [ makeWrapper ];
buildInputs = [ 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 \
--set JAVA_HOME "${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 = {
inherit jre; # Used by the NixOS module to select the supported jre
};
meta = with lib; {
homepage = "https://kafka.apache.org";
description = "High-throughput distributed messaging system";
license = licenses.asl20;
sourceProvenance = with sourceTypes; [ binaryBytecode ];
maintainers = [ maintainers.ragge ];
platforms = platforms.unix;
};
}
in with lib; mapAttrs'
(majorVersion: versionInfo: nameValuePair "apacheKafka_${majorVersion}" (build versionInfo))
versionMap

View File

@ -17955,9 +17955,11 @@ with pkgs;
apacheAnt = callPackage ../development/tools/build-managers/apache-ant { };
ant = apacheAnt;
inherit (callPackages ../servers/apache-kafka { })
apacheKafka_3_5
apacheKafka_3_6;
apacheKafka = apacheKafka_3_6;
apacheKafka_3_5 = callPackage ../servers/apache-kafka { majorVersion = "3.5"; };
apacheKafka_3_6 = callPackage ../servers/apache-kafka { majorVersion = "3.6"; };
apng2gif = callPackage ../tools/graphics/apng2gif { };