2014-11-20 11:29:07 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
cfg = config.services.hbase;
|
|
|
|
|
2014-11-20 15:22:07 +00:00
|
|
|
configFile = pkgs.writeText "hbase-site.xml" ''
|
|
|
|
<configuration>
|
|
|
|
<property>
|
|
|
|
<name>hbase.rootdir</name>
|
|
|
|
<value>file://${cfg.dataDir}/hbase</value>
|
|
|
|
</property>
|
|
|
|
<property>
|
|
|
|
<name>hbase.zookeeper.property.dataDir</name>
|
|
|
|
<value>${cfg.dataDir}/zookeeper</value>
|
|
|
|
</property>
|
|
|
|
</configuration>
|
|
|
|
'';
|
|
|
|
|
2018-11-08 10:59:03 +00:00
|
|
|
configDir = pkgs.runCommand "hbase-config-dir" { preferLocalBuild = true; } ''
|
2014-11-20 15:22:07 +00:00
|
|
|
mkdir -p $out
|
|
|
|
cp ${cfg.package}/conf/* $out/
|
|
|
|
rm $out/hbase-site.xml
|
|
|
|
ln -s ${configFile} $out/hbase-site.xml
|
|
|
|
'' ;
|
|
|
|
|
2014-11-20 11:29:07 +00:00
|
|
|
in {
|
|
|
|
|
|
|
|
###### interface
|
|
|
|
|
|
|
|
options = {
|
|
|
|
|
|
|
|
services.hbase = {
|
|
|
|
|
|
|
|
enable = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
|
|
|
description = ''
|
|
|
|
Whether to run HBase.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
package = mkOption {
|
|
|
|
type = types.package;
|
|
|
|
default = pkgs.hbase;
|
2016-01-17 18:34:55 +00:00
|
|
|
defaultText = "pkgs.hbase";
|
2014-11-20 11:29:07 +00:00
|
|
|
example = literalExample "pkgs.hbase";
|
|
|
|
description = ''
|
|
|
|
HBase package to use.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
user = mkOption {
|
2019-08-08 21:48:27 +01:00
|
|
|
type = types.str;
|
2014-11-20 11:29:07 +00:00
|
|
|
default = "hbase";
|
|
|
|
description = ''
|
|
|
|
User account under which HBase runs.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
group = mkOption {
|
2019-08-08 21:48:27 +01:00
|
|
|
type = types.str;
|
2014-11-20 11:29:07 +00:00
|
|
|
default = "hbase";
|
|
|
|
description = ''
|
|
|
|
Group account under which HBase runs.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
dataDir = mkOption {
|
|
|
|
type = types.path;
|
|
|
|
default = "/var/lib/hbase";
|
|
|
|
description = ''
|
|
|
|
Specifies location of HBase database files. This location should be
|
|
|
|
writable and readable for the user the HBase service runs as
|
|
|
|
(hbase by default).
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
logDir = mkOption {
|
|
|
|
type = types.path;
|
|
|
|
default = "/var/log/hbase";
|
|
|
|
description = ''
|
|
|
|
Specifies the location of HBase log files.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
###### implementation
|
|
|
|
|
|
|
|
config = mkIf config.services.hbase.enable {
|
|
|
|
|
2019-02-24 12:23:11 +00:00
|
|
|
systemd.tmpfiles.rules = [
|
|
|
|
"d '${cfg.dataDir}' - ${cfg.user} ${cfg.group} - -"
|
|
|
|
"d '${cfg.logDir}' - ${cfg.user} ${cfg.group} - -"
|
|
|
|
];
|
|
|
|
|
2014-11-20 11:29:07 +00:00
|
|
|
systemd.services.hbase = {
|
|
|
|
description = "HBase Server";
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
|
|
|
|
environment = {
|
|
|
|
JAVA_HOME = "${pkgs.jre}";
|
|
|
|
HBASE_LOG_DIR = cfg.logDir;
|
|
|
|
};
|
|
|
|
|
|
|
|
serviceConfig = {
|
|
|
|
User = cfg.user;
|
|
|
|
Group = cfg.group;
|
2014-11-20 15:22:07 +00:00
|
|
|
ExecStart = "${cfg.package}/bin/hbase --config ${configDir} master start";
|
2014-11-20 11:29:07 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2018-06-30 00:58:35 +01:00
|
|
|
users.users.hbase = {
|
2014-11-20 11:29:07 +00:00
|
|
|
description = "HBase Server user";
|
|
|
|
group = "hbase";
|
|
|
|
uid = config.ids.uids.hbase;
|
|
|
|
};
|
|
|
|
|
2018-06-30 00:58:35 +01:00
|
|
|
users.groups.hbase.gid = config.ids.gids.hbase;
|
2014-11-20 11:29:07 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
}
|