about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--hosts/tahoe/services.nix5
-rw-r--r--modules/services/grafana/default.nix15
2 files changed, 15 insertions, 5 deletions
diff --git a/hosts/tahoe/services.nix b/hosts/tahoe/services.nix
index 8481bd0..0202316 100644
--- a/hosts/tahoe/services.nix
+++ b/hosts/tahoe/services.nix
@@ -12,7 +12,10 @@ in {
     };
     unifi = { enable = true; };
     prometheus = { enable = true; };
-    grafana = { enable = true; };
+    grafana = {
+      enable = true;
+      vhostName = "dash.fcuny.net";
+    };
     gitea = {
       enable = true;
       stateDir = "/var/lib/gitea";
diff --git a/modules/services/grafana/default.nix b/modules/services/grafana/default.nix
index 20d5a19..bcb52e2 100644
--- a/modules/services/grafana/default.nix
+++ b/modules/services/grafana/default.nix
@@ -5,6 +5,11 @@ let
 in {
   options.my.services.grafana = with lib; {
     enable = mkEnableOption "grafana observability stack";
+    vhostName = mkOption {
+      type = types.str;
+      example = "dash.fcuny.net";
+      description = "Name for the virtual host";
+    };
   };
 
   config = lib.mkIf cfg.enable {
@@ -27,16 +32,18 @@ in {
       };
     };
 
-    services.nginx.virtualHosts."dash.fcuny.xyz" = {
+    services.nginx.virtualHosts."${cfg.vhostName}" = {
       forceSSL = true;
-      useACMEHost = "dash.fcuny.xyz";
+      useACMEHost = cfg.vhostName;
       locations."/" = {
-        proxyPass = "http://127.0.0.1:3000";
+        proxyPass = "http://${config.services.grafana.addr}:${
+            toString config.services.grafana.port
+          }";
         proxyWebsockets = true;
       };
     };
 
-    security.acme.certs."dash.fcuny.xyz" = {
+    security.acme.certs."${cfg.vhostName}" = {
       dnsProvider = "gcloud";
       credentialsFile = secrets."acme/credentials".path;
     };