mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-07-19 08:31:01 +03:00

After final improvements to the official formatter implementation,
this commit now performs the first treewide reformat of Nix files using it.
This is part of the implementation of RFC 166.
Only "inactive" files are reformatted, meaning only files that
aren't being touched by any PR with activity in the past 2 months.
This is to avoid conflicts for PRs that might soon be merged.
Later we can do a full treewide reformat to get the rest,
which should not cause as many conflicts.
A CI check has already been running for some time to ensure that new and
already-formatted files are formatted, so the files being reformatted here
should also stay formatted.
This commit was automatically created and can be verified using
nix-build https://github.com/infinisil/treewide-nixpkgs-reformat-script/archive/a08b3a4d199c6124ac5b36a889d9099b4383463f.tar.gz \
--argstr baseRev 0128fbb0a5
result/bin/apply-formatting $NIXPKGS_PATH
78 lines
2 KiB
Nix
78 lines
2 KiB
Nix
{
|
|
config,
|
|
lib,
|
|
pkgs,
|
|
options,
|
|
...
|
|
}:
|
|
|
|
let
|
|
cfg = config.services.prometheus.exporters.nut;
|
|
inherit (lib)
|
|
mkOption
|
|
types
|
|
optionalString
|
|
concatStringsSep
|
|
;
|
|
in
|
|
{
|
|
port = 9199;
|
|
extraOpts = {
|
|
nutServer = mkOption {
|
|
type = types.str;
|
|
default = "127.0.0.1";
|
|
description = ''
|
|
Hostname or address of the NUT server
|
|
'';
|
|
};
|
|
nutUser = mkOption {
|
|
type = types.str;
|
|
default = "";
|
|
example = "nut";
|
|
description = ''
|
|
The user to log in into NUT server. If set, passwordPath should
|
|
also be set.
|
|
|
|
Default NUT configs usually permit reading variables without
|
|
authentication.
|
|
'';
|
|
};
|
|
passwordPath = mkOption {
|
|
type = types.nullOr types.path;
|
|
default = null;
|
|
apply = final: if final == null then null else toString final;
|
|
description = ''
|
|
A run-time path to the nutUser password file, which should be
|
|
provisioned outside of Nix store.
|
|
'';
|
|
};
|
|
nutVariables = mkOption {
|
|
type = types.listOf types.str;
|
|
default = [ ];
|
|
description = ''
|
|
List of NUT variable names to monitor.
|
|
|
|
If no variables are set, all numeric variables will be exported automatically.
|
|
See the [upstream docs](https://github.com/DRuggeri/nut_exporter?tab=readme-ov-file#variables-and-information)
|
|
for more information.
|
|
'';
|
|
};
|
|
};
|
|
serviceOpts = {
|
|
script = ''
|
|
${optionalString (
|
|
cfg.passwordPath != null
|
|
) "export NUT_EXPORTER_PASSWORD=$(cat ${toString cfg.passwordPath})"}
|
|
${pkgs.prometheus-nut-exporter}/bin/nut_exporter \
|
|
--nut.server=${cfg.nutServer} \
|
|
--web.listen-address="${cfg.listenAddress}:${toString cfg.port}" \
|
|
${optionalString (cfg.nutUser != "") "--nut.username=${cfg.nutUser}"} \
|
|
${
|
|
optionalString (
|
|
cfg.nutVariables != [ ]
|
|
) "--nut.vars_enable=${concatStringsSep "," cfg.nutVariables}"
|
|
} \
|
|
${concatStringsSep " " cfg.extraFlags}
|
|
'';
|
|
};
|
|
}
|