Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change clickhouse extraConfig type to yaml #99

Merged
merged 2 commits into from
Feb 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions doc/clickhouse.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ Clickhouse has [HTTP Interface](https://clickhouse.com/docs/en/interfaces/http)
{
services.clickhouse."clickhouse-1" = {
enable = true;
extraConfig = ''
http_port: 9050
'';
extraConfig = {
http_port = 9050
};
};
}
```
Expand Down
8 changes: 2 additions & 6 deletions nix/clickhouse/clickhouse_test.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,12 @@
services.clickhouse."clickhouse1" = {
enable = true;
port = 9000;
extraConfig = ''
http_port: 9050
'';
extraConfig.http_port = 9050;
};
services.clickhouse."clickhouse2" = {
enable = true;
port = 9001;
extraConfig = ''
http_port: 9051
'';
extraConfig.http_port = 9051;
initialDatabases = [
{
name = "sample_db";
Expand Down
41 changes: 23 additions & 18 deletions nix/clickhouse/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
{ pkgs, lib, name, config, ... }:
let
inherit (lib) types;
yamlFormat = pkgs.formats.yaml { };
in
{
options = {
Expand All @@ -27,9 +28,9 @@ in
};

extraConfig = lib.mkOption {
type = types.lines;
type = yamlFormat.type;
description = "Additional configuration to be appended to `clickhouse-config.yaml`.";
default = "";
default = { };
};

initialDatabases = lib.mkOption {
Expand Down Expand Up @@ -73,22 +74,26 @@ in
default = {
processes =
let
clickhouseConfig = pkgs.writeText "clickhouse-config.yaml" ''
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
${config.extraConfig}
'';
clickhouseConfig = yamlFormat.generate "clickhouse-config.yaml" (
{
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";
};
};
} // config.extraConfig
);
in
{
# DB initialization
Expand Down
Loading