From 5d81fcdf3726eb6140ca53de5780fda5aea14afd Mon Sep 17 00:00:00 2001 From: D Anzorge Date: Mon, 7 Sep 2020 02:17:12 +0200 Subject: [PATCH] nixos/netdata: add config option for disabling analytics Option disables analytics through the DO_NOT_TRACK environment variable, as detailed in https://learn.netdata.cloud/docs/agent/anonymous-statistics Default is analytics off --- nixos/modules/services/monitoring/netdata.nix | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/nixos/modules/services/monitoring/netdata.nix b/nixos/modules/services/monitoring/netdata.nix index d5b679097b30..007024c04ce5 100644 --- a/nixos/modules/services/monitoring/netdata.nix +++ b/nixos/modules/services/monitoring/netdata.nix @@ -123,9 +123,20 @@ in { "error log" = "syslog"; }; ''; - }; + }; + + enableAnalyticsReporting = mkOption { + type = types.bool; + default = false; + description = '' + Enable reporting of anonymous usage statistics to Netdata Inc. via either + Google Analytics (in versions prior to 1.29.4), or Netdata Inc.'s + self-hosted PostHog (in versions 1.29.4 and later). + See: + ''; }; }; + }; config = mkIf cfg.enable { assertions = @@ -140,8 +151,12 @@ in { wantedBy = [ "multi-user.target" ]; path = (with pkgs; [ curl gawk which ]) ++ lib.optional cfg.python.enable (pkgs.python3.withPackages cfg.python.extraPackages); + environment = { + PYTHONPATH = "${cfg.package}/libexec/netdata/python.d/python_modules"; + } // lib.optionalAttrs (!cfg.enableAnalyticsReporting) { + DO_NOT_TRACK = "1"; + }; serviceConfig = { - Environment="PYTHONPATH=${cfg.package}/libexec/netdata/python.d/python_modules"; ExecStart = "${cfg.package}/bin/netdata -P /run/netdata/netdata.pid -D -c ${configFile}"; ExecReload = "${pkgs.util-linux}/bin/kill -s HUP -s USR1 -s USR2 $MAINPID"; TimeoutStopSec = 60;