1{
2 config,
3 lib,
4 pkgs,
5 options,
6 ...
7}:
8
9let
10 cfg = config.services.prometheus.exporters.v2ray;
11 inherit (lib) mkOption types concatStringsSep;
12in
13{
14 port = 9299;
15 extraOpts = {
16 v2rayEndpoint = mkOption {
17 type = types.str;
18 default = "127.0.0.1:54321";
19 description = ''
20 v2ray grpc api endpoint
21 '';
22 };
23 };
24 serviceOpts = {
25 serviceConfig = {
26 ExecStart = ''
27 ${pkgs.prometheus-v2ray-exporter}/bin/v2ray-exporter \
28 --v2ray-endpoint ${cfg.v2rayEndpoint} \
29 --listen ${cfg.listenAddress}:${toString cfg.port} \
30 ${concatStringsSep " \\\n " cfg.extraFlags}
31 '';
32 };
33 };
34}