nixos/hbase: add settings option for hbase-site.xml

This commit is contained in:
Vanilla 2021-11-18 10:34:13 +08:00
parent 82b5e86be8
commit cb5f41a067
No known key found for this signature in database
GPG Key ID: 3750028ED04FA42E

View File

@ -5,18 +5,24 @@ with lib;
let
cfg = config.services.hbase;
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>
'';
defaultConfig = {
"hbase.rootdir" = "file://${cfg.dataDir}/hbase";
"hbase.zookeeper.property.dataDir" = "${cfg.dataDir}/zookeeper";
};
buildProperty = configAttr:
(builtins.concatStringsSep "\n"
(lib.mapAttrsToList
(name: value: ''
<property>
<name>${name}</name>
<value>${builtins.toString value}</value>
</property>
'')
configAttr));
configFile = pkgs.writeText "hbase-site.xml"
(buildProperty (defaultConfig // cfg.settings));
configDir = pkgs.runCommand "hbase-config-dir" { preferLocalBuild = true; } ''
mkdir -p $out
@ -85,6 +91,14 @@ in {
'';
};
settings = mkOption {
type = with lib.types; attrsOf (oneOf [ str int bool ]);
default = defaultConfig;
description = ''
configurations in hbase-site.xml, see <link xlink:href="https://github.com/apache/hbase/blob/master/hbase-server/src/test/resources/hbase-site.xml"/> for details.
'';
};
};
};