nixpkgs/nixos/modules/services/monitoring/prometheus/exporters/fastly.nix
pennae ef176dcf7e nixos/*: automatically convert option descriptions
conversions were done using https://github.com/pennae/nix-doc-munge
using (probably) rev f34e145 running

    nix-doc-munge nixos/**/*.nix
    nix-doc-munge --import nixos/**/*.nix

the tool ensures that only changes that could affect the generated
manual *but don't* are committed, other changes require manual review
and are discarded.
2022-08-31 16:32:53 +02:00

42 lines
1.2 KiB
Nix

{ config, lib, pkgs, options }:
with lib;
let cfg = config.services.prometheus.exporters.fastly;
in
{
port = 9118;
extraOpts = {
debug = mkEnableOption (lib.mdDoc "Debug logging mode for fastly-exporter");
configFile = mkOption {
type = types.nullOr types.path;
default = null;
description = lib.mdDoc ''
Path to a fastly-exporter configuration file.
Example one can be generated with `fastly-exporter --config-file-example`.
'';
example = "./fastly-exporter-config.txt";
};
tokenPath = mkOption {
type = types.nullOr types.path;
apply = final: if final == null then null else toString final;
description = lib.mdDoc ''
A run-time path to the token file, which is supposed to be provisioned
outside of Nix store.
'';
};
};
serviceOpts = {
script = ''
${optionalString (cfg.tokenPath != null)
"export FASTLY_API_TOKEN=$(cat ${toString cfg.tokenPath})"}
${pkgs.prometheus-fastly-exporter}/bin/fastly-exporter \
-listen http://${cfg.listenAddress}:${toString cfg.port}
${optionalString cfg.debug "-debug true"} \
${optionalString (cfg.configFile != null) "-config-file ${cfg.configFile}"}
'';
};
}