1 { config, pkgs, lib, ... }:
6 cfg = config.services.confd;
9 backend = "${cfg.backend}"
10 confdir = "${cfg.confDir}"
11 interval = ${toString cfg.interval}
12 nodes = [ ${concatMapStringsSep "," (s: ''"${s}"'') cfg.nodes}, ]
13 prefix = "${cfg.prefix}"
14 log-level = "${cfg.logLevel}"
15 watch = ${boolToString cfg.watch}
19 options.services.confd = {
20 enable = mkEnableOption (lib.mdDoc "confd service");
23 description = lib.mdDoc "Confd config storage backend to use.";
25 type = types.enum ["etcd" "consul" "redis" "zookeeper"];
29 description = lib.mdDoc "Confd check interval.";
35 description = lib.mdDoc "Confd list of nodes to connect to.";
36 default = [ "http://127.0.0.1:2379" ];
37 type = types.listOf types.str;
41 description = lib.mdDoc "Confd, whether to watch etcd config for changes.";
47 description = lib.mdDoc "The string to prefix to keys.";
53 description = lib.mdDoc "Confd log level.";
55 type = types.enum ["info" "debug"];
59 description = lib.mdDoc "The path to the confd configs.";
60 default = "/etc/confd";
65 description = lib.mdDoc "Confd package to use.";
67 defaultText = literalExpression "pkgs.confd";
72 config = mkIf cfg.enable {
73 systemd.services.confd = {
74 description = "Confd Service.";
75 wantedBy = [ "multi-user.target" ];
76 after = [ "network.target" ];
78 ExecStart = "${cfg.package}/bin/confd";
83 "confd/confd.toml".text = confdConfig;
86 environment.systemPackages = [ cfg.package ];
88 services.etcd.enable = mkIf (cfg.backend == "etcd") (mkDefault true);