nixos/prometheus-exporters: add option renaming for submodules
Adds the functionality to create option renamings and removals for exporter submodules as in nixos/modules/rename.nix.
This commit is contained in:
parent
77ccb1fe6a
commit
fb6f0a48bb
|
@ -102,9 +102,10 @@ let
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
mkSubModule = { name, port, extraOpts, ... }: {
|
mkSubModule = { name, port, extraOpts, imports }: {
|
||||||
${name} = mkOption {
|
${name} = mkOption {
|
||||||
type = types.submodule {
|
type = types.submodule {
|
||||||
|
inherit imports;
|
||||||
options = (mkExporterOpts {
|
options = (mkExporterOpts {
|
||||||
inherit name port;
|
inherit name port;
|
||||||
} // extraOpts);
|
} // extraOpts);
|
||||||
|
@ -117,13 +118,15 @@ let
|
||||||
mkSubModules = (foldl' (a: b: a//b) {}
|
mkSubModules = (foldl' (a: b: a//b) {}
|
||||||
(mapAttrsToList (name: opts: mkSubModule {
|
(mapAttrsToList (name: opts: mkSubModule {
|
||||||
inherit name;
|
inherit name;
|
||||||
inherit (opts) port serviceOpts;
|
inherit (opts) port;
|
||||||
extraOpts = opts.extraOpts or {};
|
extraOpts = opts.extraOpts or {};
|
||||||
|
imports = opts.imports or [];
|
||||||
}) exporterOpts)
|
}) exporterOpts)
|
||||||
);
|
);
|
||||||
|
|
||||||
mkExporterConf = { name, conf, serviceOpts }:
|
mkExporterConf = { name, conf, serviceOpts }:
|
||||||
mkIf conf.enable {
|
mkIf conf.enable {
|
||||||
|
warnings = conf.warnings or [];
|
||||||
networking.firewall.extraCommands = mkIf conf.openFirewall (concatStrings [
|
networking.firewall.extraCommands = mkIf conf.openFirewall (concatStrings [
|
||||||
"ip46tables -A nixos-fw ${conf.firewallFilter} "
|
"ip46tables -A nixos-fw ${conf.firewallFilter} "
|
||||||
"-m comment --comment ${name}-exporter -j nixos-fw-accept"
|
"-m comment --comment ${name}-exporter -j nixos-fw-accept"
|
||||||
|
|
|
@ -113,7 +113,7 @@
|
||||||
specific options and configuration:
|
specific options and configuration:
|
||||||
<programlisting>
|
<programlisting>
|
||||||
# nixpgs/nixos/modules/services/prometheus/exporters/postfix.nix
|
# nixpgs/nixos/modules/services/prometheus/exporters/postfix.nix
|
||||||
{ config, lib, pkgs }:
|
{ config, lib, pkgs, options }:
|
||||||
|
|
||||||
with lib;
|
with lib;
|
||||||
|
|
||||||
|
@ -184,4 +184,42 @@ in
|
||||||
</listitem>
|
</listitem>
|
||||||
</itemizedlist>
|
</itemizedlist>
|
||||||
</section>
|
</section>
|
||||||
|
<section xml:id="module-services-prometheus-exporters-update-exporter-module">
|
||||||
|
<title>Updating an exporter module</title>
|
||||||
|
<para>
|
||||||
|
Should an exporter option change at some point, it is possible to add
|
||||||
|
information about the change to the exporter definition similar to
|
||||||
|
<literal>nixpkgs/nixos/modules/rename.nix</literal>:
|
||||||
|
<programlisting>
|
||||||
|
{ config, lib, pkgs, options }:
|
||||||
|
|
||||||
|
with lib;
|
||||||
|
|
||||||
|
let
|
||||||
|
cfg = config.services.prometheus.exporters.nginx;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
port = 9113;
|
||||||
|
extraOpts = {
|
||||||
|
# additional module options
|
||||||
|
# ...
|
||||||
|
};
|
||||||
|
serviceOpts = {
|
||||||
|
# service configuration
|
||||||
|
# ...
|
||||||
|
};
|
||||||
|
imports = [
|
||||||
|
# 'services.prometheus.exporters.nginx.telemetryEndpoint' -> 'services.prometheus.exporters.nginx.telemetryPath'
|
||||||
|
(mkRenamedOptionModule [ "telemetryEndpoint" ] [ "telemetryPath" ])
|
||||||
|
|
||||||
|
# removed option 'services.prometheus.exporters.nginx.insecure'
|
||||||
|
(mkRemovedOptionModule [ "insecure" ] ''
|
||||||
|
This option was replaced by 'prometheus.exporters.nginx.sslVerify' which defaults to true.
|
||||||
|
'')
|
||||||
|
({ options.warnings = options.warnings; })
|
||||||
|
];
|
||||||
|
}
|
||||||
|
</programlisting>
|
||||||
|
</para>
|
||||||
|
</section>
|
||||||
</chapter>
|
</chapter>
|
||||||
|
|
Loading…
Reference in a new issue