nixos/hbase: refactor settings option
instead of keeping a defaultConfig value around, set that value as the default of the option and explicitly use the option default instead. this also allows us to write a defaultText that makes sense and is in proximity to the definition of the default.
This commit is contained in:
@@ -1,14 +1,10 @@
|
|||||||
{ config, lib, pkgs, ... }:
|
{ config, options, lib, pkgs, ... }:
|
||||||
|
|
||||||
with lib;
|
with lib;
|
||||||
|
|
||||||
let
|
let
|
||||||
cfg = config.services.hbase;
|
cfg = config.services.hbase;
|
||||||
|
opt = options.services.hbase;
|
||||||
defaultConfig = {
|
|
||||||
"hbase.rootdir" = "file://${cfg.dataDir}/hbase";
|
|
||||||
"hbase.zookeeper.property.dataDir" = "${cfg.dataDir}/zookeeper";
|
|
||||||
};
|
|
||||||
|
|
||||||
buildProperty = configAttr:
|
buildProperty = configAttr:
|
||||||
(builtins.concatStringsSep "\n"
|
(builtins.concatStringsSep "\n"
|
||||||
@@ -23,7 +19,7 @@ let
|
|||||||
|
|
||||||
configFile = pkgs.writeText "hbase-site.xml"
|
configFile = pkgs.writeText "hbase-site.xml"
|
||||||
''<configuration>
|
''<configuration>
|
||||||
${buildProperty (defaultConfig // cfg.settings)}
|
${buildProperty (opt.settings.default // cfg.settings)}
|
||||||
</configuration>
|
</configuration>
|
||||||
'';
|
'';
|
||||||
|
|
||||||
@@ -96,7 +92,16 @@ in {
|
|||||||
|
|
||||||
settings = mkOption {
|
settings = mkOption {
|
||||||
type = with lib.types; attrsOf (oneOf [ str int bool ]);
|
type = with lib.types; attrsOf (oneOf [ str int bool ]);
|
||||||
default = defaultConfig;
|
default = {
|
||||||
|
"hbase.rootdir" = "file://${cfg.dataDir}/hbase";
|
||||||
|
"hbase.zookeeper.property.dataDir" = "${cfg.dataDir}/zookeeper";
|
||||||
|
};
|
||||||
|
defaultText = literalExpression ''
|
||||||
|
{
|
||||||
|
"hbase.rootdir" = "file://''${config.${opt.dataDir}}/hbase";
|
||||||
|
"hbase.zookeeper.property.dataDir" = "''${config.${opt.dataDir}}/zookeeper";
|
||||||
|
}
|
||||||
|
'';
|
||||||
description = ''
|
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.
|
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.
|
||||||
'';
|
'';
|
||||||
|
|||||||
Reference in New Issue
Block a user