From cb5f41a0678b1dd628148cdd281c698e238ae635 Mon Sep 17 00:00:00 2001 From: Vanilla Date: Thu, 18 Nov 2021 10:34:13 +0800 Subject: nixos/hbase: add settings option for hbase-site.xml --- nixos/modules/services/databases/hbase.nix | 38 ++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 12 deletions(-) (limited to 'nixos/modules/services/databases') diff --git a/nixos/modules/services/databases/hbase.nix b/nixos/modules/services/databases/hbase.nix index ff01a1bcd98..183c8a2f46d 100644 --- a/nixos/modules/services/databases/hbase.nix +++ b/nixos/modules/services/databases/hbase.nix @@ -5,18 +5,24 @@ with lib; let cfg = config.services.hbase; - configFile = pkgs.writeText "hbase-site.xml" '' - - - hbase.rootdir - file://${cfg.dataDir}/hbase - - - hbase.zookeeper.property.dataDir - ${cfg.dataDir}/zookeeper - - - ''; + defaultConfig = { + "hbase.rootdir" = "file://${cfg.dataDir}/hbase"; + "hbase.zookeeper.property.dataDir" = "${cfg.dataDir}/zookeeper"; + }; + + buildProperty = configAttr: + (builtins.concatStringsSep "\n" + (lib.mapAttrsToList + (name: value: '' + + ${name} + ${builtins.toString value} + + '') + 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 for details. + ''; + }; + }; }; -- cgit 1.4.1