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