8 cfg = config.services.clickhouse;
16 services.clickhouse = {
18 enable = lib.mkEnableOption "ClickHouse database server";
20 package = lib.mkPackageOption pkgs "clickhouse" { };
28 config = lib.mkIf cfg.enable {
30 users.users.clickhouse = {
32 uid = config.ids.uids.clickhouse;
34 description = "ClickHouse server user";
37 users.groups.clickhouse.gid = config.ids.gids.clickhouse;
39 systemd.services.clickhouse = {
40 description = "ClickHouse server";
42 wantedBy = [ "multi-user.target" ];
44 after = [ "network.target" ];
50 ConfigurationDirectory = "clickhouse-server";
51 AmbientCapabilities = "CAP_SYS_NICE";
52 StateDirectory = "clickhouse";
53 LogsDirectory = "clickhouse";
54 ExecStart = "${cfg.package}/bin/clickhouse-server --config-file=/etc/clickhouse-server/config.xml";
55 TimeoutStartSec = "infinity";
59 # Switching off watchdog is very important for sd_notify to work correctly.
60 CLICKHOUSE_WATCHDOG_ENABLE = "0";
65 "clickhouse-server/config.xml" = {
66 source = "${cfg.package}/etc/clickhouse-server/config.xml";
69 "clickhouse-server/users.xml" = {
70 source = "${cfg.package}/etc/clickhouse-server/users.xml";
74 environment.systemPackages = [ cfg.package ];
76 # startup requires a `/etc/localtime` which only if exists if `time.timeZone != null`
77 time.timeZone = lib.mkDefault "UTC";