hackens-org-configurations/hosts/hackens-org/modules/mqtt2prometheus/default.nix

40 lines
1.2 KiB
Nix
Raw Normal View History

2022-04-25 00:53:18 +02:00
{ pkgs, lib, config, ... }:
let
cfg = config.services.mqtt2prometheus;
in
{
options.services.mqtt2prometheus = {
enable = lib.mkEnableOption "Enable mqtt2Prometheus";
package = lib.mkOption {
type = lib.types.package;
description = "Which mqtt2prometheus package to use";
};
listenAddress = lib.mkOption {
type = lib.types.str;
default = "127.0.0.1";
description = "listen address for HTTP server used to expose metrics";
};
listenPort = lib.mkOption {
type = lib.types.port;
default = 9641;
description = "HTTP port used to expose metrics";
};
config = lib.mkOption { # à nixifier
type = lib.types.path;
description = "Path to config file";
};
};
config = lib.mkIf cfg.enable {
systemd.services."mqtt2prometheus" = {
enable = true;
description = "MQTT client which exposes metrics for prometheus monitoring software";
after = [ "network.target" ];
serviceConfig = {
ExecStart = "${cfg.package}/bin/mqtt2prometheus -config ${cfg.config} -listen-address ${cfg.listenAddress} -listen-port ${toString cfg.listenPort}";
Restart = "always";
};
wantedBy = [ "multi-user.target" ];
};
};
}