From 40ddf3e2c6c18122ba4d783252870adb7c5dff92 Mon Sep 17 00:00:00 2001 From: Luke Granger-Brown Date: Thu, 24 Nov 2022 15:29:36 +0000 Subject: [PATCH 1/4] unifi-poller: rename to unpoller. --- .../monitoring/{unifi-poller => unpoller}/default.nix | 8 ++++---- pkgs/top-level/aliases.nix | 1 + pkgs/top-level/all-packages.nix | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) rename pkgs/servers/monitoring/{unifi-poller => unpoller}/default.nix (85%) diff --git a/pkgs/servers/monitoring/unifi-poller/default.nix b/pkgs/servers/monitoring/unpoller/default.nix similarity index 85% rename from pkgs/servers/monitoring/unifi-poller/default.nix rename to pkgs/servers/monitoring/unpoller/default.nix index 857d90c54902..77a68d18ef82 100644 --- a/pkgs/servers/monitoring/unifi-poller/default.nix +++ b/pkgs/servers/monitoring/unpoller/default.nix @@ -4,12 +4,12 @@ }: buildGoModule rec { - pname = "unifi-poller"; + pname = "unpoller"; version = "2.2.0"; src = fetchFromGitHub { - owner = "unifi-poller"; - repo = "unifi-poller"; + owner = "unpoller"; + repo = "unpoller"; rev = "v${version}"; hash = "sha256-jPatTo+5nQ73AETXI88x/bma0wlY333DNvuyaYQTgz0="; }; @@ -26,7 +26,7 @@ buildGoModule rec { meta = with lib; { description = "Collect ALL UniFi Controller, Site, Device & Client Data - Export to InfluxDB or Prometheus"; - homepage = "https://github.com/unifi-poller/unifi-poller"; + homepage = "https://github.com/unpoller/unpoller"; changelog = "https://github.com/unpoller/unpoller/releases/tag/v${version}"; license = licenses.mit; maintainers = with maintainers; [ ]; diff --git a/pkgs/top-level/aliases.nix b/pkgs/top-level/aliases.nix index b4756035241e..7edde704d8fd 100644 --- a/pkgs/top-level/aliases.nix +++ b/pkgs/top-level/aliases.nix @@ -1531,6 +1531,7 @@ mapAliases ({ ufraw = throw "ufraw is unmaintained and has been removed from nixpkgs. Its successor, nufraw, doesn't seem to be stable enough. Consider using Darktable for now"; # Added 2020-01-11 ultrastardx-beta = throw "'ultrastardx-beta' has been renamed to/replaced by 'ultrastardx'"; # Converted to throw 2022-02-22 unicorn-emu = unicorn; # Added 2020-10-29 + unifi-poller = unpoller; # Added 2022-11-24 unifiStable = unifi6; # Added 2020-12-28 unity3d = throw "'unity3d' is unmaintained, has seen no updates in years and depends on deprecated GTK2"; # Added 2022-06-16 untrunc = untrunc-anthwlock; # Added 2021-02-01 diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 7c9d2aac1ee0..c91b142a7e87 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -38095,7 +38095,7 @@ with pkgs; texlive = texlive.combined.scheme-medium; }; - unifi-poller = callPackage ../servers/monitoring/unifi-poller {}; + unpoller = callPackage ../servers/monitoring/unpoller {}; fac-build = callPackage ../development/tools/build-managers/fac { inherit (darwin.apple_sdk.frameworks) CoreServices; From ffcd97b521a413eb53b532952be847406a9495ed Mon Sep 17 00:00:00 2001 From: Luke Granger-Brown Date: Thu, 24 Nov 2022 15:30:14 +0000 Subject: [PATCH 2/4] nixos/unifi-poller: rename to unpoller. --- nixos/modules/module-list.nix | 2 +- .../{unifi-poller.nix => unpoller.nix} | 26 +++++++++++-------- 2 files changed, 16 insertions(+), 12 deletions(-) rename nixos/modules/services/monitoring/{unifi-poller.nix => unpoller.nix} (91%) diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix index 59d6cf165f18..3d6f1e84ecec 100644 --- a/nixos/modules/module-list.nix +++ b/nixos/modules/module-list.nix @@ -724,7 +724,7 @@ ./services/monitoring/thanos.nix ./services/monitoring/tremor-rs.nix ./services/monitoring/tuptime.nix - ./services/monitoring/unifi-poller.nix + ./services/monitoring/unpoller.nix ./services/monitoring/ups.nix ./services/monitoring/uptime.nix ./services/monitoring/vmagent.nix diff --git a/nixos/modules/services/monitoring/unifi-poller.nix b/nixos/modules/services/monitoring/unpoller.nix similarity index 91% rename from nixos/modules/services/monitoring/unifi-poller.nix rename to nixos/modules/services/monitoring/unpoller.nix index b30e28a3ecc9..f0ced5513d64 100644 --- a/nixos/modules/services/monitoring/unifi-poller.nix +++ b/nixos/modules/services/monitoring/unpoller.nix @@ -3,15 +3,19 @@ with lib; let - cfg = config.services.unifi-poller; + cfg = config.services.unpoller; - configFile = pkgs.writeText "unifi-poller.json" (generators.toJSON {} { + configFile = pkgs.writeText "unpoller.json" (generators.toJSON {} { inherit (cfg) poller influxdb loki prometheus unifi; }); in { - options.services.unifi-poller = { - enable = mkEnableOption (lib.mdDoc "unifi-poller"); + imports = [ + (lib.mkRenamedOptionModule [ "services" "unifi-poller" ] [ "services" "unpoller" ]) + ]; + + options.services.unpoller = { + enable = mkEnableOption (lib.mdDoc "unpoller"); poller = { debug = mkOption { @@ -86,8 +90,8 @@ in { }; pass = mkOption { type = types.path; - default = pkgs.writeText "unifi-poller-influxdb-default.password" "unifipoller"; - defaultText = literalExpression "unifi-poller-influxdb-default.password"; + default = pkgs.writeText "unpoller-influxdb-default.password" "unifipoller"; + defaultText = literalExpression "unpoller-influxdb-default.password"; description = lib.mdDoc '' Path of a file containing the password for influxdb. This file needs to be readable by the unifi-poller user. @@ -135,8 +139,8 @@ in { }; pass = mkOption { type = types.path; - default = pkgs.writeText "unifi-poller-loki-default.password" ""; - defaultText = "unifi-poller-influxdb-default.password"; + default = pkgs.writeText "unpoller-loki-default.password" ""; + defaultText = "unpoller-influxdb-default.password"; description = lib.mdDoc '' Path of a file containing the password for Loki. This file needs to be readable by the unifi-poller user. @@ -184,8 +188,8 @@ in { }; pass = mkOption { type = types.path; - default = pkgs.writeText "unifi-poller-unifi-default.password" "unifi"; - defaultText = literalExpression "unifi-poller-unifi-default.password"; + default = pkgs.writeText "unpoller-unifi-default.password" "unifi"; + defaultText = literalExpression "unpoller-unifi-default.password"; description = lib.mdDoc '' Path of a file containing the password for the unifi service user. This file needs to be readable by the unifi-poller user. @@ -303,7 +307,7 @@ in { wantedBy = [ "multi-user.target" ]; after = [ "network.target" ]; serviceConfig = { - ExecStart = "${pkgs.unifi-poller}/bin/unifi-poller --config ${configFile}"; + ExecStart = "${pkgs.unpoller}/bin/unpoller --config ${configFile}"; Restart = "always"; PrivateTmp = true; ProtectHome = true; From c7918fed9e51371bf7783a59492683f3533331dd Mon Sep 17 00:00:00 2001 From: Luke Granger-Brown Date: Thu, 24 Nov 2022 15:30:34 +0000 Subject: [PATCH 3/4] nixos/prometheus/unifi-poller: rename to unpoller. --- .../services/monitoring/prometheus/exporters.nix | 11 ++++++++--- .../exporters/{unifi-poller.nix => unpoller.nix} | 10 +++++----- nixos/tests/prometheus-exporters.nix | 8 ++++---- 3 files changed, 17 insertions(+), 12 deletions(-) rename nixos/modules/services/monitoring/prometheus/exporters/{unifi-poller.nix => unpoller.nix} (71%) diff --git a/nixos/modules/services/monitoring/prometheus/exporters.nix b/nixos/modules/services/monitoring/prometheus/exporters.nix index 22b78981b2cc..2451f46ba7d7 100644 --- a/nixos/modules/services/monitoring/prometheus/exporters.nix +++ b/nixos/modules/services/monitoring/prometheus/exporters.nix @@ -73,7 +73,7 @@ let "tor" "unbound" "unifi" - "unifi-poller" + "unpoller" "v2ray" "varnish" "wireguard" @@ -230,6 +230,10 @@ in options.services.prometheus.exporters = mkOption { type = types.submodule { options = (mkSubModules); + imports = [ + ../../../misc/assertions.nix + (lib.mkRenamedOptionModule [ "unifi-poller" ] [ "unpoller" ]) + ]; }; description = lib.mdDoc "Prometheus exporter configuration"; default = {}; @@ -293,13 +297,14 @@ in Please specify either 'services.prometheus.exporters.sql.configuration' or 'services.prometheus.exporters.sql.configFile' ''; - } ] ++ (flip map (attrNames cfg) (exporter: { + } ] ++ (flip map (attrNames exporterOpts) (exporter: { assertion = cfg.${exporter}.firewallFilter != null -> cfg.${exporter}.openFirewall; message = '' The `firewallFilter'-option of exporter ${exporter} doesn't have any effect unless `openFirewall' is set to `true'! ''; - })); + })) ++ config.services.prometheus.exporters.assertions; + warnings = config.services.prometheus.exporters.warnings; }] ++ [(mkIf config.services.minio.enable { services.prometheus.exporters.minio.minioAddress = mkDefault "http://localhost:9000"; services.prometheus.exporters.minio.minioAccessKey = mkDefault config.services.minio.accessKey; diff --git a/nixos/modules/services/monitoring/prometheus/exporters/unifi-poller.nix b/nixos/modules/services/monitoring/prometheus/exporters/unpoller.nix similarity index 71% rename from nixos/modules/services/monitoring/prometheus/exporters/unifi-poller.nix rename to nixos/modules/services/monitoring/prometheus/exporters/unpoller.nix index 35de31df88e6..5cd1e2c65e90 100644 --- a/nixos/modules/services/monitoring/prometheus/exporters/unifi-poller.nix +++ b/nixos/modules/services/monitoring/prometheus/exporters/unpoller.nix @@ -3,9 +3,9 @@ with lib; let - cfg = config.services.prometheus.exporters.unifi-poller; + cfg = config.services.prometheus.exporters.unpoller; - configFile = pkgs.writeText "prometheus-unifi-poller-exporter.json" (generators.toJSON {} { + configFile = pkgs.writeText "prometheus-unpoller-exporter.json" (generators.toJSON {} { poller = { inherit (cfg.log) debug quiet; }; unifi = { inherit (cfg) controllers; }; influxdb.disable = true; @@ -21,8 +21,8 @@ in { port = 9130; extraOpts = { - inherit (options.services.unifi-poller.unifi) controllers; - inherit (options.services.unifi-poller) loki; + inherit (options.services.unpoller.unifi) controllers; + inherit (options.services.unpoller) loki; log = { debug = mkEnableOption (lib.mdDoc "debug logging including line numbers, high resolution timestamps, per-device logs."); quiet = mkEnableOption (lib.mdDoc "startup and error logs only."); @@ -31,7 +31,7 @@ in { }; serviceOpts.serviceConfig = { - ExecStart = "${pkgs.unifi-poller}/bin/unpoller --config ${configFile}"; + ExecStart = "${pkgs.unpoller}/bin/unpoller --config ${configFile}"; DynamicUser = false; }; } diff --git a/nixos/tests/prometheus-exporters.nix b/nixos/tests/prometheus-exporters.nix index d91fc52f1cb4..cdf666378fa3 100644 --- a/nixos/tests/prometheus-exporters.nix +++ b/nixos/tests/prometheus-exporters.nix @@ -1244,15 +1244,15 @@ let ''; }; - unifi-poller = { - nodeName = "unifi_poller"; + unpoller = { + nodeName = "unpoller"; exporterConfig.enable = true; exporterConfig.controllers = [{ }]; exporterTest = '' - wait_for_unit("prometheus-unifi-poller-exporter.service") + wait_for_unit("prometheus-unpoller-exporter.service") wait_for_open_port(9130) succeed( - "curl -sSf localhost:9130/metrics | grep 'unifipoller_build_info{.\\+} 1'" + "curl -sSf localhost:9130/metrics | grep 'unpoller_build_info{.\\+} 1'" ) ''; }; From 7b7bff387b620b3356095fc62e0e88a69adf761f Mon Sep 17 00:00:00 2001 From: Luke Granger-Brown Date: Thu, 24 Nov 2022 15:30:57 +0000 Subject: [PATCH 4/4] nixos: update release notes for unifi-poller --> unpoller. --- nixos/doc/manual/from_md/release-notes/rl-2305.section.xml | 7 +++++++ nixos/doc/manual/release-notes/rl-2305.section.md | 2 ++ 2 files changed, 9 insertions(+) diff --git a/nixos/doc/manual/from_md/release-notes/rl-2305.section.xml b/nixos/doc/manual/from_md/release-notes/rl-2305.section.xml index e54bec81b2f3..b43af0758e5e 100644 --- a/nixos/doc/manual/from_md/release-notes/rl-2305.section.xml +++ b/nixos/doc/manual/from_md/release-notes/rl-2305.section.xml @@ -139,6 +139,13 @@ the Nix store. + + + The unifi-poller package and corresponding + NixOS module have been renamed to unpoller + to match upstream. + + diff --git a/nixos/doc/manual/release-notes/rl-2305.section.md b/nixos/doc/manual/release-notes/rl-2305.section.md index 0e5b97c89846..fd58623a68ef 100644 --- a/nixos/doc/manual/release-notes/rl-2305.section.md +++ b/nixos/doc/manual/release-notes/rl-2305.section.md @@ -44,3 +44,5 @@ In addition to numerous new and upgraded packages, this release has the followin - A new `virtualisation.rosetta` module was added to allow running `x86_64` binaries through [Rosetta](https://developer.apple.com/documentation/apple-silicon/about-the-rosetta-translation-environment) inside virtualised NixOS guests on Apple silicon. This feature works by default with the [UTM](https://docs.getutm.app/) virtualisation [package](https://search.nixos.org/packages?channel=unstable&show=utm&from=0&size=1&sort=relevance&type=packages&query=utm). - Resilio sync secret keys can now be provided using a secrets file at runtime, preventing these secrets from ending up in the Nix store. + +- The `unifi-poller` package and corresponding NixOS module have been renamed to `unpoller` to match upstream.