mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-12-16 10:43:27 +00:00
2e751c0772
the conversion procedure is simple: - find all things that look like options, ie calls to either `mkOption` or `lib.mkOption` that take an attrset. remember the attrset as the option - for all options, find a `description` attribute who's value is not a call to `mdDoc` or `lib.mdDoc` - textually convert the entire value of the attribute to MD with a few simple regexes (the set from mdize-module.sh) - if the change produced a change in the manual output, discard - if the change kept the manual unchanged, add some text to the description to make sure we've actually found an option. if the manual changes this time, keep the converted description this procedure converts 80% of nixos options to markdown. around 2000 options remain to be inspected, but most of those fail the "does not change the manual output check": currently the MD conversion process does not faithfully convert docbook tags like <code> and <package>, so any option using such tags will not be converted at all.
126 lines
3.4 KiB
Nix
126 lines
3.4 KiB
Nix
{ config, lib, pkgs, ... }:
|
|
|
|
with lib;
|
|
|
|
let
|
|
cfg = config.services.trickster;
|
|
in
|
|
{
|
|
imports = [
|
|
(mkRenamedOptionModule [ "services" "trickster" "origin" ] [ "services" "trickster" "origin-url" ])
|
|
];
|
|
|
|
options = {
|
|
services.trickster = {
|
|
enable = mkOption {
|
|
type = types.bool;
|
|
default = false;
|
|
description = lib.mdDoc ''
|
|
Enable Trickster.
|
|
'';
|
|
};
|
|
|
|
package = mkOption {
|
|
type = types.package;
|
|
default = pkgs.trickster;
|
|
defaultText = literalExpression "pkgs.trickster";
|
|
description = lib.mdDoc ''
|
|
Package that should be used for trickster.
|
|
'';
|
|
};
|
|
|
|
configFile = mkOption {
|
|
type = types.nullOr types.path;
|
|
default = null;
|
|
description = lib.mdDoc ''
|
|
Path to configuration file.
|
|
'';
|
|
};
|
|
|
|
instance-id = mkOption {
|
|
type = types.nullOr types.int;
|
|
default = null;
|
|
description = lib.mdDoc ''
|
|
Instance ID for when running multiple processes (default null).
|
|
'';
|
|
};
|
|
|
|
log-level = mkOption {
|
|
type = types.str;
|
|
default = "info";
|
|
description = lib.mdDoc ''
|
|
Level of Logging to use (debug, info, warn, error) (default "info").
|
|
'';
|
|
};
|
|
|
|
metrics-port = mkOption {
|
|
type = types.port;
|
|
default = 8082;
|
|
description = lib.mdDoc ''
|
|
Port that the /metrics endpoint will listen on.
|
|
'';
|
|
};
|
|
|
|
origin-type = mkOption {
|
|
type = types.enum [ "prometheus" "influxdb" ];
|
|
default = "prometheus";
|
|
description = lib.mdDoc ''
|
|
Type of origin (prometheus, influxdb)
|
|
'';
|
|
};
|
|
|
|
origin-url = mkOption {
|
|
type = types.str;
|
|
default = "http://prometheus:9090";
|
|
description = lib.mdDoc ''
|
|
URL to the Origin. Enter it like you would in grafana, e.g., http://prometheus:9090 (default http://prometheus:9090).
|
|
'';
|
|
};
|
|
|
|
profiler-port = mkOption {
|
|
type = types.nullOr types.port;
|
|
default = null;
|
|
description = lib.mdDoc ''
|
|
Port that the /debug/pprof endpoint will listen on.
|
|
'';
|
|
};
|
|
|
|
proxy-port = mkOption {
|
|
type = types.port;
|
|
default = 9090;
|
|
description = lib.mdDoc ''
|
|
Port that the Proxy server will listen on.
|
|
'';
|
|
};
|
|
|
|
};
|
|
};
|
|
|
|
config = mkIf cfg.enable {
|
|
systemd.services.trickster = {
|
|
description = "Reverse proxy cache and time series dashboard accelerator";
|
|
after = [ "network.target" ];
|
|
wantedBy = [ "multi-user.target" ];
|
|
serviceConfig = {
|
|
DynamicUser = true;
|
|
ExecStart = ''
|
|
${cfg.package}/bin/trickster \
|
|
-log-level ${cfg.log-level} \
|
|
-metrics-port ${toString cfg.metrics-port} \
|
|
-origin-type ${cfg.origin-type} \
|
|
-origin-url ${cfg.origin-url} \
|
|
-proxy-port ${toString cfg.proxy-port} \
|
|
${optionalString (cfg.configFile != null) "-config ${cfg.configFile}"} \
|
|
${optionalString (cfg.profiler-port != null) "-profiler-port ${cfg.profiler-port}"} \
|
|
${optionalString (cfg.instance-id != null) "-instance-id ${cfg.instance-id}"}
|
|
'';
|
|
ExecReload = "${pkgs.coreutils}/bin/kill -HUP $MAINPID";
|
|
Restart = "always";
|
|
};
|
|
};
|
|
};
|
|
|
|
meta.maintainers = with maintainers; [ _1000101 ];
|
|
|
|
}
|