1 { config, options, lib, pkgs, ... }:
3 cfg = config.services.hbase-standalone;
4 opt = options.services.hbase-standalone;
6 buildProperty = configAttr:
7 (builtins.concatStringsSep "\n"
12 <value>${builtins.toString value}</value>
17 configFile = pkgs.writeText "hbase-site.xml"
19 ${buildProperty (opt.settings.default // cfg.settings)}
23 configDir = pkgs.runCommand "hbase-config-dir" { preferLocalBuild = true; } ''
25 cp ${cfg.package}/conf/* $out/
26 rm $out/hbase-site.xml
27 ln -s ${configFile} $out/hbase-site.xml
33 (lib.mkRenamedOptionModule [ "services" "hbase" ] [ "services" "hbase-standalone" ])
39 services.hbase-standalone = {
41 enable = lib.mkEnableOption ''
42 HBase master in standalone mode with embedded regionserver and zookeper.
43 Do not use this configuration for production nor for evaluating HBase performance
46 package = lib.mkPackageOption pkgs "hbase" { };
52 User account under which HBase runs.
56 group = lib.mkOption {
60 Group account under which HBase runs.
64 dataDir = lib.mkOption {
65 type = lib.types.path;
66 default = "/var/lib/hbase";
68 Specifies location of HBase database files. This location should be
69 writable and readable for the user the HBase service runs as
74 logDir = lib.mkOption {
75 type = lib.types.path;
76 default = "/var/log/hbase";
78 Specifies the location of HBase log files.
82 settings = lib.mkOption {
83 type = with lib.types; attrsOf (oneOf [ str int bool ]);
85 "hbase.rootdir" = "file://${cfg.dataDir}/hbase";
86 "hbase.zookeeper.property.dataDir" = "${cfg.dataDir}/zookeeper";
88 defaultText = lib.literalExpression ''
90 "hbase.rootdir" = "file://''${config.${opt.dataDir}}/hbase";
91 "hbase.zookeeper.property.dataDir" = "''${config.${opt.dataDir}}/zookeeper";
95 configurations in hbase-site.xml, see <https://github.com/apache/hbase/blob/master/hbase-server/src/test/resources/hbase-site.xml> for details.
102 ###### implementation
104 config = lib.mkIf cfg.enable {
106 systemd.tmpfiles.rules = [
107 "d '${cfg.dataDir}' - ${cfg.user} ${cfg.group} - -"
108 "d '${cfg.logDir}' - ${cfg.user} ${cfg.group} - -"
111 systemd.services.hbase = {
112 description = "HBase Server";
113 wantedBy = [ "multi-user.target" ];
116 # JRE 15 removed option `UseConcMarkSweepGC` which is needed.
117 JAVA_HOME = "${pkgs.jre8}";
118 HBASE_LOG_DIR = cfg.logDir;
124 ExecStart = "${cfg.package}/bin/hbase --config ${configDir} master start";
128 users.users.hbase = {
129 description = "HBase Server user";
131 uid = config.ids.uids.hbase;
134 users.groups.hbase.gid = config.ids.gids.hbase;