about summary refs log tree commit diff
path: root/pkgs/by-name/dr/druid/package.nix
blob: 3d8c59b3f02ad38650c14560a9a1824ce22aab1b (plain) (blame)
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
{
  lib,
  stdenv,
  fetchurl,
  extensions ? { },
  libJars ? [ ],
  nixosTests,
  mysqlSupport ? true,
}:
let
  inherit (lib)
    concatStringsSep
    licenses
    maintainers
    mapAttrsToList
    optionalString
    forEach
    ;
in
stdenv.mkDerivation (finalAttrs: {
  pname = "apache-druid";
  version = "30.0.0";

  src = fetchurl {
    url = "mirror://apache/druid/${finalAttrs.version}/apache-druid-${finalAttrs.version}-bin.tar.gz";
    hash = "sha256-mRYorVkNzM94LP53G78eW20N5UsvMP7Lv4rAysmPwXw=";
  };

  mysqlConnector = fetchurl {
    url = "https://repo1.maven.org/maven2/mysql/mysql-connector-java/5.1.48/mysql-connector-java-5.1.48.jar";
    hash = "sha256-VuJsqqOCH1rkr0T5x09mz4uE6gFRatOAPLsOkEm27Kg=";
  };

  dontBuild = true;

  loadExtensions = (
    concatStringsSep "\n" (
      mapAttrsToList (
        dir: files:
        ''
          if ! test -d $out/extensions/${dir}; then
               mkdir $out/extensions/${dir};
           fi
        ''
        + concatStringsSep "\n" (
          forEach files (file: ''
            if test -d ${file} ; then
              cp  ${file}/* $out/extensions/${dir}/
            else
              cp ${file} $out/extensions/${dir}/
            fi
          '')
        )
      ) extensions
    )
  );

  loadJars = concatStringsSep "\n" (forEach libJars (jar: "cp ${jar} $out/lib/"));

  installPhase = ''
    runHook preInstall
    mkdir $out
    mv * $out
    ${optionalString mysqlSupport "cp ${finalAttrs.mysqlConnector} $out/extensions/mysql-metadata-storage"}
    ${finalAttrs.loadExtensions}
    ${finalAttrs.loadJars}
    runHook postInstall
  '';

  passthru = {
    tests = nixosTests.druid.default.passthru.override { druidPackage = finalAttrs.finalPackage; };
  };

  meta = {
    description = "Apache Druid: a high performance real-time analytics database";
    homepage = "https://github.com/apache/druid";
    license = licenses.asl20;
    maintainers = with maintainers; [ vsharathchandra ];
    mainProgram = "druid";
  };

})