From 487bf05e97ce9aec1fb56734f2e9c9eb9b22c565 Mon Sep 17 00:00:00 2001 From: Abhishek Singh Date: Thu, 22 Feb 2024 19:06:45 +0530 Subject: [PATCH] clickhouse: add new options and internal options --- nix/clickhouse/default.nix | 103 +++++++++++++++++++++++++++++++------ 1 file changed, 87 insertions(+), 16 deletions(-) diff --git a/nix/clickhouse/default.nix b/nix/clickhouse/default.nix index a2a31d9d..09f974de 100644 --- a/nix/clickhouse/default.nix +++ b/nix/clickhouse/default.nix @@ -27,6 +27,82 @@ in description = "The clickhouse data directory"; }; + loggerLevel = lib.mkOption { + type = types.str; + default = "warning"; + description = "Log level for clickhouse"; + }; + + loggerConsole = lib.mkOption { + type = types.int; + default = 1; + description = "Log to console if not daemon mode and is tty"; + }; + + defaultProfile = lib.mkOption { + type = types.str; + default = "default"; + description = "Default profile of settings"; + }; + + defaultDatabase = lib.mkOption { + type = types.str; + default = "default"; + description = "Default database"; + }; + + tcp_port = lib.mkOption { + type = types.str; + internal = true; + readOnly = true; + default = toString config.port; + description = "Log to console if not daemon mode and is tty"; + }; + + path = lib.mkOption { + type = types.str; + internal = true; + readOnly = true; + default = "${config.dataDir}/clickhouse"; + description = "Path to data directory"; + }; + + tmp_path = lib.mkOption { + type = types.str; + internal = true; + readOnly = true; + default = "${config.dataDir}/clickhouse/tmp"; + description = "Path to temporary data for processing hard queries"; + }; + + user_files_path = lib.mkOption { + type = types.str; + internal = true; + readOnly = true; + default = "${config.dataDir}/clickhouse/user_files"; + description = "Directory with user provided files that are accessible by 'file' table function"; + }; + + format_schema_path = lib.mkOption { + type = types.str; + internal = true; + readOnly = true; + default = "${config.dataDir}/clickhouse/format_schemas"; + description = "Directory containing schema files for various input formats"; + }; + + user_directories = lib.mkOption { + type = yamlFormat.type; + internal = true; + readOnly = true; + default = { + users_xml = { + path = "${config.package}/etc/clickhouse-server/users.xml"; + }; + }; + description = "Sources to read users, roles, access rights, profiles of settings, quotas"; + }; + extraConfig = lib.mkOption { type = yamlFormat.type; description = "Additional configuration to be appended to `clickhouse-config.yaml`."; @@ -78,22 +154,17 @@ in lib.recursiveUpdate config.extraConfig { - logger = { - level = "warning"; - console = 1; - }; - tcp_port = "${toString config.port}"; - default_profile = "default"; - default_database = "default"; - path = "${config.dataDir}/clickhouse"; - tmp_path = "${config.dataDir}/clickhouse/tmp"; - user_files_path = "${config.dataDir}/clickhouse/user_files"; - format_schema_path = "${config.dataDir}/clickhouse/format_schemas"; - user_directories = { - users_xml = { - path = "${config.package}/etc/clickhouse-server/users.xml"; - }; - }; + logger.level = config.loggerLevel; + logger.console = config.loggerConsole; + default_profile = config.defaultProfile; + default_database = config.defaultDatabase; + inherit (config) + tcp_port + path + tmp_path + user_files_path + format_schema_path + user_directories; } ); in