1 { config, pkgs, lib, ... }:
6 cfg = config.services.prometheus.sachet;
7 configFile = pkgs.writeText "sachet.yml" (builtins.toJSON cfg.configuration);
11 services.prometheus.sachet = {
12 enable = mkEnableOption "Sachet, an SMS alerting tool for the Prometheus Alertmanager";
14 configuration = mkOption {
15 type = types.nullOr types.attrs;
17 example = literalExpression ''
21 # environment variables gets expanded at runtime
22 account_sid = "$TWILIO_ACCOUNT";
23 auth_token = "$TWILIO_TOKEN";
26 templates = [ ./some-template.tmpl ];
30 to = [ "+33123456789" ];
31 text = "{{ template \"message\" . }}";
36 Sachet's configuration as a nix attribute set.
42 default = "localhost";
44 The address Sachet will listen to.
52 The port Sachet will listen to.
59 config = mkIf cfg.enable {
60 assertions = singleton {
61 assertion = cfg.configuration != null;
62 message = "Cannot enable Sachet without a configuration.";
65 systemd.services.sachet = {
66 wantedBy = [ "multi-user.target" ];
67 after = [ "network.target" "network-online.target" ];
69 ${pkgs.envsubst}/bin/envsubst -i "${configFile}" > /tmp/sachet.yaml
70 exec ${pkgs.prometheus-sachet}/bin/sachet -config /tmp/sachet.yaml -listen-address ${cfg.address}:${builtins.toString cfg.port}
76 ProtectSystem = "strict";
78 ProtectKernelTunables = true;
79 ProtectKernelModules = true;
80 ProtectControlGroups = true;
84 WorkingDirectory = "/tmp/";