From 0e007e41c55512fe90af3d5ae415c8e8916c038c Mon Sep 17 00:00:00 2001
From: Florian Sesser <florian@private.storage>
Date: Mon, 13 Feb 2023 16:57:09 +0000
Subject: [PATCH] Fix Grafana warnings

---
 nixos/modules/monitoring/server/grafana.nix | 23 ++++++++++++---------
 1 file changed, 13 insertions(+), 10 deletions(-)

diff --git a/nixos/modules/monitoring/server/grafana.nix b/nixos/modules/monitoring/server/grafana.nix
index bf742a46..8cce63e0 100644
--- a/nixos/modules/monitoring/server/grafana.nix
+++ b/nixos/modules/monitoring/server/grafana.nix
@@ -91,21 +91,24 @@ in {
 
     services.grafana = {
       enable = true;
-      inherit domain; 
-      port = 2342;
-      addr = "127.0.0.1";
+
+      settings = {
+        server.domain = "${toString domain}";
+        server.http_port = 2342;
+        server.http_addr = "127.0.0.1";
+      };
 
       # No phoning home
-      analytics.reporting.enable = false;
+      settings.analytics.reporting_enabled = false;
 
       # Force Grafana to believe it is reachable via https on the default port
       # number because that's where the nginx that forwards traffic to it is
       # listening.  Grafana's own server listens on an internal address that
       # doesn't matter to anyone except our nginx instance.
-      rootUrl = "https://%(domain)s/";
+      settings.server.root_url = "https://%(domain)s/";
 
       # Defend against DNS rebinding attacks.
-      settings.server.enforce_domain = "true";
+      settings.server.enforce_domain = true;
       # Same time zone for all users by default
       settings.date_formats.default_timezone = "UTC";
 
@@ -115,7 +118,7 @@ in {
       } // grafanaAuth;
 
       # Give users that come through GSuite SSO the highest possible privileges:
-      users.autoAssignOrgRole = "Editor";
+      settings.users.auto_assign_org_role = "Editor";
 
       # Read the admin password from a file in our secrets folder:
       settings.security.admin_password = "$__file{${toString cfg.adminPasswordFile}}";
@@ -163,7 +166,7 @@ in {
     };
 
     # nginx reverse proxy
-    security.acme.email = cfg.letsEncryptAdminEmail;
+    security.acme.defaults.email = cfg.letsEncryptAdminEmail;
     security.acme.acceptTerms = true;
     services.nginx = {
       enable = true;
@@ -181,7 +184,7 @@ in {
         enableACME = true;
         forceSSL = true;
         locations."/" = {
-          proxyPass = "http://127.0.0.1:${toString config.services.grafana.port}";
+          proxyPass = "http://127.0.0.1:${toString config.services.grafana.settings.server.http_port}";
           proxyWebsockets = true;
         };
         locations."/metrics" = {
@@ -193,7 +196,7 @@ in {
             allow ::1;
             deny all;
           '';
-          proxyPass = "http://127.0.0.1:${toString config.services.grafana.port}";
+          proxyPass = "http://127.0.0.1:${toString config.services.grafana.settings.server.http_port}";
         };
       };
     };
-- 
GitLab