ocamlPackages.hxd: 0.3.2 -> 0.3.3 (#364231)
[NixPkgs.git] / nixos / modules / services / databases / clickhouse.nix
blob18251d2e4d77c2bf365e411fac3f2b5b6b09a22a
2   config,
3   lib,
4   pkgs,
5   ...
6 }:
7 let
8   cfg = config.services.clickhouse;
9 in
12   ###### interface
14   options = {
16     services.clickhouse = {
18       enable = lib.mkEnableOption "ClickHouse database server";
20       package = lib.mkPackageOption pkgs "clickhouse" { };
22     };
24   };
26   ###### implementation
28   config = lib.mkIf cfg.enable {
30     users.users.clickhouse = {
31       name = "clickhouse";
32       uid = config.ids.uids.clickhouse;
33       group = "clickhouse";
34       description = "ClickHouse server user";
35     };
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" ];
46       serviceConfig = {
47         Type = "notify";
48         User = "clickhouse";
49         Group = "clickhouse";
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";
56       };
58       environment = {
59         # Switching off watchdog is very important for sd_notify to work correctly.
60         CLICKHOUSE_WATCHDOG_ENABLE = "0";
61       };
62     };
64     environment.etc = {
65       "clickhouse-server/config.xml" = {
66         source = "${cfg.package}/etc/clickhouse-server/config.xml";
67       };
69       "clickhouse-server/users.xml" = {
70         source = "${cfg.package}/etc/clickhouse-server/users.xml";
71       };
72     };
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";
79   };