1 { config, lib, pkgs, options, ... }:
4 cfg = config.services.prometheus.exporters.nut;
15 nutServer = mkOption {
17 default = "127.0.0.1";
19 Hostname or address of the NUT server
27 The user to log in into NUT server. If set, passwordPath should
30 Default NUT configs usually permit reading variables without
34 passwordPath = mkOption {
35 type = types.nullOr types.path;
37 apply = final: if final == null then null else toString final;
39 A run-time path to the nutUser password file, which should be
40 provisioned outside of Nix store.
43 nutVariables = mkOption {
44 type = types.listOf types.str;
47 List of NUT variable names to monitor.
49 If no variables are set, all numeric variables will be exported automatically.
50 See the [upstream docs](https://github.com/DRuggeri/nut_exporter?tab=readme-ov-file#variables-and-information)
57 ${optionalString (cfg.passwordPath != null)
58 "export NUT_EXPORTER_PASSWORD=$(cat ${toString cfg.passwordPath})"}
59 ${pkgs.prometheus-nut-exporter}/bin/nut_exporter \
60 --nut.server=${cfg.nutServer} \
61 --web.listen-address="${cfg.listenAddress}:${toString cfg.port}" \
62 ${optionalString (cfg.nutUser != "") "--nut.username=${cfg.nutUser}"} \
63 ${optionalString (cfg.nutVariables != []) "--nut.vars_enable=${concatStringsSep "," cfg.nutVariables}"} \
64 ${concatStringsSep " " cfg.extraFlags}