i2pd-exporter/service.nix
2024-05-20 00:47:07 +02:00

67 lines
1.9 KiB
Nix

{ lib, pkgs, config, utils, ... }:
with lib;
let
cfg = config.services.prometheus.exporters.i2pd-exporter;
settingsFormat = pkgs.formats.json { };
in
{
options.services.prometheus.exporters.i2pd-exporter = {
enable = mkEnableOption (lib.mdDoc "lemmy a federated alternative to reddit in rust");
listenAddress = mkOption {
type = with types; nullOr str;
default = "127.0.0.1";
description = lib.mdDoc "The connection URI to use. Takes priority over the configuration file if set.";
};
port = mkOption {
type = types.port;
default = 5733;
description = lib.mdDoc "The connection URI to use. Takes priority over the configuration file if set.";
};
routerAddress = mkOption {
type = with types; nullOr str;
default = "http://127.0.0.1:7650";
description = lib.mdDoc "The connection URI to use. Takes priority over the configuration file if set.";
};
routerPassword = mkOption {
type = with types; nullOr str;
default = "itoopie";
description = lib.mdDoc "The connection URI to use. Takes priority over the configuration file if set.";
};
systemd.services.i2pd-exporter =
{
description = "I2PD prometheus exporter";
environment = {
IP = cfg.services.prometheus.exporters.i2pd-exporter.listenAddress;
PORT = cfg.services.prometheus.exporters.i2pd-exporter.port;
ADDRESS = cfg.services.prometheus.exporters.i2pd-exporter.routerAddress;
PASSWORD = cfg.services.prometheus.exporters.i2pd-exporter.routerPassword;
};
wantedBy = [ "multi-user.target" ];
serviceConfig = {
DynamicUser = true;
RuntimeDirectory = "i2pd-exporter";
ExecStart = "${cfg.server.package}/bin/i2pdexporter";
PrivateTmp = true;
MemoryDenyWriteExecute = true;
NoNewPrivileges = true;
};
};
};
}