1{ stdenv, lib, fetchurl, zip, unzip
2, jdk, python3
3, confFile ? ""
4, extraLibraryPaths ? []
5, extraJars ? []
6, testers
7}:
8
9stdenv.mkDerivation (finalAttrs: {
10 pname = "apache-storm";
11 version = "2.6.2";
12 name = "${finalAttrs.pname}-${finalAttrs.version}";
13
14 src = fetchurl {
15 url = "mirror://apache/storm/${finalAttrs.name}/${finalAttrs.name}.tar.gz";
16 hash = "sha256-ZAwsVKWTzc/++UQTNnOHdK5hiDDT5j6453DCLWi+7TA=";
17 };
18
19 nativeBuildInputs = [ zip unzip ];
20
21 installPhase = ''
22 mkdir -p $out/share/${finalAttrs.name}
23 mv public $out/docs
24 mv examples $out/share/${finalAttrs.name}/.
25
26 mv external extlib* lib $out/.
27 mv conf bin $out/.
28 mv log4j2 $out/conf/.
29 '';
30
31 fixupPhase = ''
32 patchShebangs $out
33 # Fix python reference
34 sed -i \
35 -e '19iPYTHON=${python3}/bin/python' \
36 -e 's|#!/usr/bin/.*python|#!${python3}/bin/python|' \
37 $out/bin/storm
38 sed -i \
39 -e 's|#!/usr/bin/.*python|#!${python3}/bin/python|' \
40 -e "s|STORM_CONF_DIR = .*|STORM_CONF_DIR = os.getenv('STORM_CONF_DIR','$out/conf')|" \
41 -e 's|STORM_LOG4J2_CONF_DIR =.*|STORM_LOG4J2_CONF_DIR = os.path.join(STORM_CONF_DIR, "log4j2")|' \
42 $out/bin/storm.py
43
44 # Default jdk location
45 sed -i -e 's|export JAVA_HOME=.*|export JAVA_HOME="${jdk.home}"|' \
46 $out/conf/storm-env.sh
47 unzip $out/lib/storm-client-${finalAttrs.version}.jar defaults.yaml;
48 zip -d $out/lib/storm-client-${finalAttrs.version}.jar defaults.yaml;
49 sed -i \
50 -e 's|java.library.path: .*|java.library.path: "${lib.concatStringsSep ":" extraLibraryPaths}"|' \
51 -e 's|storm.log4j2.conf.dir: .*|storm.log4j2.conf.dir: "conf/log4j2"|' \
52 defaults.yaml
53 ${lib.optionalString (confFile != "") "cat ${confFile} >> defaults.yaml"}
54 mv defaults.yaml $out/conf;
55
56 # Link to extra jars
57 cd $out/lib;
58 ${lib.concatMapStrings (jar: "ln -s ${jar};\n") extraJars}
59 '';
60
61 dontStrip = true;
62
63 passthru.tests.version = testers.testVersion {
64 package = finalAttrs.finalPackage;
65 command = "storm version";
66 };
67
68 meta = with lib; {
69 homepage = "https://storm.apache.org/";
70 description = "Distributed realtime computation system";
71 sourceProvenance = with sourceTypes; [ binaryBytecode ];
72 license = licenses.asl20;
73 maintainers = with maintainers; [ edwtjo vizanto ];
74 platforms = with platforms; unix;
75 };
76})