nixos/prometheus/exporters: Remove all with lib; usage

Fixes issues described in #208242 for this part of the nixpkgs tree.

There are no behavioral changes in this, it only adjusts the code so
that it is easier to understand.
This commit is contained in:
Pyrox 2024-04-24 14:41:17 -04:00
parent 9d9758f548
commit ae359d1ef2
No known key found for this signature in database
GPG Key ID: 8CDF3F7CAA53A0F5
65 changed files with 307 additions and 129 deletions

View File

@ -1,9 +1,8 @@
{ config, lib, pkgs, options, ... }:
with lib;
let
cfg = config.services.prometheus.exporters.apcupsd;
inherit (lib) mkOption types concatStringsSep;
in
{
port = 9162;

View File

@ -1,9 +1,8 @@
{ config, lib, pkgs, options, ... }:
with lib;
let
cfg = config.services.prometheus.exporters.artifactory;
inherit (lib) mkOption types concatStringsSep;
in
{
port = 9531;

View File

@ -1,9 +1,8 @@
{ config, lib, pkgs, options, ... }:
with lib;
let
cfg = config.services.prometheus.exporters.bind;
inherit (lib) mkOption types concatStringsSep;
in
{
port = 9119;

View File

@ -1,9 +1,13 @@
{ config, lib, pkgs, options, ... }:
with lib;
let
cfg = config.services.prometheus.exporters.bird;
inherit (lib)
mkOption
types
concatStringsSep
singleton
;
in
{
port = 9324;

View File

@ -1,9 +1,8 @@
{ config, lib, pkgs, options, ... }:
with lib;
let
cfg = config.services.prometheus.exporters.bitcoin;
inherit (lib) mkOption types concatStringsSep;
in
{
port = 9332;

View File

@ -1,10 +1,14 @@
{ config, lib, pkgs, options, ... }:
with lib;
let
logPrefix = "services.prometheus.exporter.blackbox";
cfg = config.services.prometheus.exporters.blackbox;
inherit (lib)
mkOption
types
concatStringsSep
escapeShellArg
;
# This ensures that we can deal with string paths, path types and
# store-path strings with context.

View File

@ -1,9 +1,14 @@
{ config, lib, pkgs, options, ... }:
with lib;
let
cfg = config.services.prometheus.exporters.buildkite-agent;
inherit (lib)
mkOption
types
concatStringsSep
optionalString
literalExpression
;
in
{
port = 9876;

View File

@ -1,9 +1,15 @@
{ config, lib, pkgs, options, ... }:
with lib;
let
cfg = config.services.prometheus.exporters.collectd;
inherit (lib)
mkOption
mkEnableOption
types
optionalString
concatStringsSep
escapeShellArg
;
in
{
port = 9103;

View File

@ -1,9 +1,8 @@
{ config, lib, pkgs, options, ... }:
with lib;
let
cfg = config.services.prometheus.exporters.dmarc;
inherit (lib) mkOption types optionalString;
json = builtins.toJSON {
inherit (cfg) folders port;

View File

@ -1,9 +1,13 @@
{ config, lib, pkgs, options, ... }:
with lib;
let
cfg = config.services.prometheus.exporters.dnsmasq;
inherit (lib)
mkOption
types
concatStringsSep
escapeShellArg
;
in
{
port = 9153;

View File

@ -1,9 +1,8 @@
{ config, lib, pkgs, options, ... }:
with lib;
let
cfg = config.services.prometheus.exporters.domain;
inherit (lib) concatStringsSep;
in
{
port = 9222;

View File

@ -1,9 +1,13 @@
{ config, lib, pkgs, options, ... }:
with lib;
let
cfg = config.services.prometheus.exporters.dovecot;
inherit (lib)
mkOption
types
escapeShellArg
concatStringsSep
;
in
{
port = 9166;

View File

@ -1,9 +1,14 @@
{ config, lib, pkgs, options, ... }:
with lib;
let
cfg = config.services.prometheus.exporters.flow;
inherit (lib)
mkOption
types
literalExpression
concatStringsSep
optionalString
;
in {
port = 9590;
extraOpts = {

View File

@ -1,9 +1,8 @@
{ config, lib, pkgs, options, ... }:
with lib;
let
cfg = config.services.prometheus.exporters.fritzbox;
inherit (lib) mkOption types concatStringsSep;
in
{
port = 9133;

View File

@ -1,8 +1,8 @@
{ config, lib, pkgs, options, ... }:
with lib;
let
cfg = config.services.prometheus.exporters.idrac;
inherit (lib) mkOption types;
configFile = if cfg.configurationPath != null
then cfg.configurationPath

View File

@ -1,7 +1,5 @@
{ config, lib, pkgs, options, ... }:
with lib;
let
cfg = config.services.prometheus.exporters.imap-mailstat;
valueToString = value:
@ -13,6 +11,15 @@ let
else "XXX ${toString value}"
)
);
inherit (lib)
mkOption
types
concatStrings
concatStringsSep
attrValues
mapAttrs
optionalString
;
createConfigFile = accounts:
# unfortunately on toTOML yet
# https://github.com/NixOS/nix/issues/3929

View File

@ -1,9 +1,8 @@
{ config, lib, pkgs, options, ... }:
with lib;
let
cfg = config.services.prometheus.exporters.influxdb;
inherit (lib) mkOption types concatStringsSep;
in
{
port = 9122;

View File

@ -1,10 +1,15 @@
{ config, lib, pkgs, options, ... }:
with lib;
let
logPrefix = "services.prometheus.exporter.ipmi";
cfg = config.services.prometheus.exporters.ipmi;
inherit (lib)
mkOption
types
concatStringsSep
optionals
escapeShellArg
;
in {
port = 9290;

View File

@ -1,9 +1,13 @@
{ config, lib, pkgs, options, ... }:
with lib;
let
cfg = config.services.prometheus.exporters.jitsi;
inherit (lib)
mkOption
types
escapeShellArg
concatStringsSep
;
in
{
port = 9700;

View File

@ -1,9 +1,14 @@
{ config, lib, pkgs, options, ... }:
with lib;
let
cfg = config.services.prometheus.exporters.json;
inherit (lib)
mkOption
types
escapeShellArg
concatStringsSep
mkRemovedOptionModule
;
in
{
port = 7979;

View File

@ -1,9 +1,14 @@
{ config, lib, pkgs, options, ... }:
with lib;
let
cfg = config.services.prometheus.exporters.junos-czerwonk;
inherit (lib)
mkOption
types
escapeShellArg
mkIf
concatStringsSep
;
configFile = if cfg.configuration != null then configurationFile else (escapeShellArg cfg.configurationFile);

View File

@ -5,10 +5,14 @@
, ...
}:
with lib;
let
cfg = config.services.prometheus.exporters.kea;
inherit (lib)
mkOption
types
mkRenamedOptionModule
literalExpression
;
in {
imports = [
(mkRenamedOptionModule [ "controlSocketPaths" ] [ "targets" ])

View File

@ -1,9 +1,8 @@
{ config, lib, pkgs, options, ... }:
with lib;
let
cfg = config.services.prometheus.exporters.keylight;
inherit (lib) concatStringsSep;
in
{
port = 9288;

View File

@ -1,9 +1,13 @@
{ config, lib, pkgs, options, ... }:
with lib;
let
cfg = config.services.prometheus.exporters.knot;
inherit (lib)
mkOption
types
literalExpression
concatStringsSep
;
in {
port = 9433;
extraOpts = {

View File

@ -1,9 +1,8 @@
{ config, lib, pkgs, options, ... }:
with lib;
let
cfg = config.services.prometheus.exporters.lnd;
inherit (lib) mkOption types concatStringsSep;
in
{
port = 9092;

View File

@ -1,9 +1,19 @@
{ config, lib, pkgs, options, ... }:
with lib;
let
cfg = config.services.prometheus.exporters.mail;
inherit (lib)
mkOption
types
mapAttrs'
nameValuePair
toLower
filterAttrs
escapeShellArg
literalExpression
mkIf
concatStringsSep
;
configFile = if cfg.configuration != null then configurationFile else (escapeShellArg cfg.configFile);

View File

@ -1,9 +1,14 @@
{ config, lib, pkgs, options, ... }:
with lib;
let
cfg = config.services.prometheus.exporters.mikrotik;
inherit (lib)
mkOption
types
literalExpression
concatStringsSep
escapeShellArg
;
in
{
port = 9436;

View File

@ -1,9 +1,14 @@
{ config, lib, pkgs, options, ... }:
with lib;
let
cfg = config.services.prometheus.exporters.minio;
inherit (lib)
mkOption
types
optionalString
concatStringsSep
escapeShellArg
;
in
{
port = 9290;

View File

@ -1,9 +1,8 @@
{ config, lib, pkgs, options, ... }:
with lib;
let
cfg = config.services.prometheus.exporters.modemmanager;
inherit (lib) mkOption types concatStringsSep;
in
{
port = 9539;

View File

@ -1,9 +1,17 @@
{ config, lib, pkgs, options, ... }:
with lib;
let
cfg = config.services.prometheus.exporters.mongodb;
inherit (lib)
mkOption
types
optionalString
getExe
length
concatStringsSep
concatMapStringsSep
escapeShellArgs
;
in
{
port = 9216;

View File

@ -1,11 +1,8 @@
{ config, lib, pkgs, options, ... }:
with lib;
let
cfg = config.services.prometheus.exporters.nats;
inherit (lib) mkOption types concatStringsSep;
in
{
port = 7777;

View File

@ -1,9 +1,13 @@
{ config, lib, pkgs, options, ... }:
with lib;
let
cfg = config.services.prometheus.exporters.nextcloud;
inherit (lib)
mkOption
types
escapeShellArg
concatStringsSep
;
in
{
port = 9205;

View File

@ -1,9 +1,16 @@
{ config, lib, pkgs, options, ... }:
with lib;
let
cfg = config.services.prometheus.exporters.nginx;
inherit (lib)
mkOption
types
mkMerge
mkRemovedOptionModule
mkRenamedOptionModule
mkIf
concatStringsSep
;
in
{
port = 9113;

View File

@ -1,9 +1,8 @@
{ config, lib, pkgs, options, ... }:
with lib;
let
cfg = config.services.prometheus.exporters.nginxlog;
inherit (lib) mkOption types;
in {
port = 9117;
extraOpts = {

View File

@ -1,9 +1,15 @@
{ config, lib, pkgs, options, ... }:
with lib;
let
cfg = config.services.prometheus.exporters.node;
inherit (lib)
mkOption
types
concatStringsSep
concatMapStringsSep
any
optionals
;
collectorIsEnabled = final: any (collector: (final == collector)) cfg.enabledCollectors;
collectorIsDisabled = final: any (collector: (final == collector)) cfg.disabledCollectors;
in

View File

@ -1,9 +1,13 @@
{ config, lib, pkgs, options, ... }:
with lib;
let
cfg = config.services.prometheus.exporters.nut;
inherit (lib)
mkOption
types
optionalString
concatStringsSep
;
in
{
port = 9199;

View File

@ -1,9 +1,8 @@
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.services.prometheus.exporters.openldap;
inherit (lib) mkOption types concatStringsSep;
in {
port = 9330;
extraOpts = {

View File

@ -1,9 +1,14 @@
{ config, lib, pkgs, options, ... }:
with lib;
let
cfg = config.services.prometheus.exporters.pgbouncer;
inherit (lib)
mkOption
types
optionals
escapeShellArg
concatStringsSep
;
in
{
port = 9127;

View File

@ -1,9 +1,13 @@
{ config, lib, pkgs, options, ... }:
with lib;
let
cfg = config.services.prometheus.exporters.pihole;
inherit (lib)
mkOption
types
mkRemovedOptionModule
optionalString
;
in
{
imports = [

View File

@ -1,9 +1,9 @@
{ config, lib, pkgs, options, ... }:
with lib;
let
cfg = config.services.prometheus.exporters.ping;
inherit (lib) mkOption types concatStringsSep;
settingsFormat = pkgs.formats.yaml {};
configFile = settingsFormat.generate "config.yml" cfg.settings;

View File

@ -1,9 +1,15 @@
{ config, lib, pkgs, options, ... }:
with lib;
let
cfg = config.services.prometheus.exporters.postfix;
inherit (lib)
mkOption
types
mkIf
escapeShellArg
concatStringsSep
optional
;
in
{
port = 9154;

View File

@ -1,9 +1,14 @@
{ config, lib, pkgs, options, ... }:
with lib;
let
cfg = config.services.prometheus.exporters.postgres;
inherit (lib)
mkOption
types
mkIf
mkForce
concatStringsSep
;
in
{
port = 9187;

View File

@ -1,9 +1,13 @@
{ config, lib, pkgs, options, ... }:
with lib;
let
cfg = config.services.prometheus.exporters.process;
inherit (lib)
mkOption
types
literalExpression
concatStringsSep
;
configFile = pkgs.writeText "process-exporter.yaml" (builtins.toJSON cfg.settings);
in
{

View File

@ -1,8 +1,14 @@
{ config, lib, pkgs, options, ... }:
with lib;
let
cfg = config.services.prometheus.exporters.pve;
inherit (lib)
mkOption
types
mkPackageOption
optionalString
optionalAttrs
;
# pve exporter requires a config file so create an empty one if configFile is not provided
emptyConfigFile = pkgs.writeTextFile {

View File

@ -1,9 +1,8 @@
{ config, lib, pkgs, options, ... }:
with lib;
let
cfg = config.services.prometheus.exporters.py-air-control;
inherit (lib) mkOption types;
workingDir = "/var/lib/${cfg.stateDir}";

View File

@ -1,9 +1,8 @@
{ config, lib, pkgs, options, ... }:
with lib;
let
cfg = config.services.prometheus.exporters.redis;
inherit (lib) concatStringsSep;
in
{
port = 9121;

View File

@ -1,9 +1,18 @@
{ config, lib, pkgs, options, ... }:
with lib;
let
cfg = config.services.prometheus.exporters.restic;
inherit (lib)
mkOption
types
concatStringsSep
mkIf
mapAttrs'
splitString
toUpper
optionalAttrs
nameValuePair
;
in
{
port = 9753;

View File

@ -1,9 +1,16 @@
{ config, lib, pkgs, options, ... }:
with lib;
let
cfg = config.services.prometheus.exporters.rspamd;
inherit (lib)
mkOption
types
replaceStrings
mkRemovedOptionModule
recursiveUpdate
concatStringsSep
literalExpression
;
mkFile = conf:
pkgs.writeText "rspamd-exporter-config.yml" (builtins.toJSON conf);

View File

@ -1,9 +1,13 @@
{ config, lib, pkgs, options, ... }:
with lib;
let
cfg = config.services.prometheus.exporters.script;
inherit (lib)
mkOption
types
literalExpression
concatStringsSep
;
configFile = pkgs.writeText "script-exporter.yaml" (builtins.toJSON cfg.settings);
in
{

View File

@ -1,9 +1,8 @@
{ config, lib, pkgs, options, ... }:
with lib;
let
cfg = config.services.prometheus.exporters.shelly;
inherit (lib) mkOption types;
in
{
port = 9784;

View File

@ -1,9 +1,8 @@
{ config, lib, pkgs, options, ... }:
with lib;
let
cfg = config.services.prometheus.exporters.smartctl;
inherit (lib) mkOption types literalExpression;
args = lib.escapeShellArgs ([
"--web.listen-address=${cfg.listenAddress}:${toString cfg.port}"
"--smartctl.path=${pkgs.smartmontools}/bin/smartctl"

View File

@ -1,9 +1,8 @@
{ config, lib, pkgs, options, ... }:
with lib;
let
cfg = config.services.prometheus.exporters.smokeping;
inherit (lib) mkOption types concatStringsSep;
goDuration = types.mkOptionType {
name = "goDuration";
description = "Go duration (https://golang.org/pkg/time/#ParseDuration)";

View File

@ -1,10 +1,15 @@
{ config, lib, pkgs, options, ... }:
with lib;
let
logPrefix = "services.prometheus.exporters.snmp";
cfg = config.services.prometheus.exporters.snmp;
inherit (lib)
mkOption
types
literalExpression
escapeShellArg
concatStringsSep
;
# This ensures that we can deal with string paths, path types and
# store-path strings with context.

View File

@ -1,7 +1,13 @@
{ config, lib, pkgs, options, ... }:
with lib;
let
cfg = config.services.prometheus.exporters.sql;
inherit (lib)
mkOption
types
mapAttrs
mapAttrsToList
concatStringsSep
;
cfgOptions = {
options = with types; {
jobs = mkOption {

View File

@ -1,9 +1,8 @@
{ config, lib, pkgs, options, ... }:
with lib;
let
cfg = config.services.prometheus.exporters.statsd;
inherit (lib) concatStringsSep;
in
{
port = 9102;

View File

@ -1,9 +1,8 @@
{ config, lib, pkgs, options, ... }:
with lib;
let
cfg = config.services.prometheus.exporters.surfboard;
inherit (lib) mkOption types concatStringsSep;
in
{
port = 9239;

View File

@ -1,9 +1,8 @@
{ config, pkgs, lib, ... }:
with lib;
let cfg = config.services.prometheus.exporters.systemd;
let
cfg = config.services.prometheus.exporters.systemd;
inherit (lib) concatStringsSep;
in {
port = 9558;

View File

@ -1,9 +1,8 @@
{ config, lib, pkgs, options, ... }:
with lib;
let
cfg = config.services.prometheus.exporters.tor;
inherit (lib) mkOption types concatStringsSep;
in
{
port = 9130;

View File

@ -5,10 +5,17 @@
, ...
}:
with lib;
let
cfg = config.services.prometheus.exporters.unbound;
inherit (lib)
mkOption
types
mkRemovedOptionModule
optionalAttrs
optionalString
mkMerge
mkIf
;
in
{
imports = [

View File

@ -1,9 +1,14 @@
{ config, lib, pkgs, options, ... }:
with lib;
let
cfg = config.services.prometheus.exporters.unifi;
inherit (lib)
mkOption
types
escapeShellArg
optionalString
concatStringsSep
;
in
{
port = 9130;

View File

@ -1,9 +1,8 @@
{ config, lib, pkgs, options, ... }:
with lib;
let
cfg = config.services.prometheus.exporters.unpoller;
inherit (lib) mkEnableOption generators;
configFile = pkgs.writeText "prometheus-unpoller-exporter.json" (generators.toJSON {} {
poller = { inherit (cfg.log) debug quiet; };

View File

@ -1,9 +1,8 @@
{ config, lib, pkgs, options, ... }:
with lib;
let
cfg = config.services.prometheus.exporters.v2ray;
inherit (lib) mkOption types concatStringsSep;
in
{
port = 9299;

View File

@ -1,9 +1,15 @@
{ config, lib, pkgs, options, ... }:
with lib;
let
cfg = config.services.prometheus.exporters.varnish;
inherit (lib)
mkOption
types
mkDefault
optional
escapeShellArg
concatStringsSep
;
in
{
port = 9131;

View File

@ -1,9 +1,15 @@
{ config, lib, pkgs, options, ... }:
with lib;
let
cfg = config.services.prometheus.exporters.wireguard;
inherit (lib)
mkOption
types
mkRenamedOptionModule
mkEnableOption
optionalString
escapeShellArg
;
in {
port = 9586;
imports = [

View File

@ -1,9 +1,14 @@
{ config, lib, pkgs, options, ... }:
with lib;
let
cfg = config.services.prometheus.exporters.zfs;
inherit (lib)
mkOption
types
concatStringsSep
concatMapStringsSep
;
in
{
port = 9134;