about summary refs log tree commit diff
path: root/modules/grafana.nix
diff options
context:
space:
mode:
authorazahi <azat@bahawi.net>2025-02-17 02:21:56 +0300
committerazahi <azat@bahawi.net>2025-02-17 02:21:56 +0300
commit59180328cda59817d71cd58c8f48ead047375064 (patch)
tree2cdd7d1bfa309839ef624c19daf283f510aacf69 /modules/grafana.nix
parent2025-02-05 (diff)
2025-02-17
Diffstat (limited to 'modules/grafana.nix')
-rw-r--r--modules/grafana.nix23
1 files changed, 11 insertions, 12 deletions
diff --git a/modules/grafana.nix b/modules/grafana.nix
index b57577d..b1745e5 100644
--- a/modules/grafana.nix
+++ b/modules/grafana.nix
@@ -6,23 +6,22 @@
   this,
   ...
 }:
-with lib;
 let
   cfg = config.nixfiles.modules.grafana;
 in
 {
   options.nixfiles.modules.grafana = {
-    enable = mkEnableOption "Grafana";
+    enable = lib.mkEnableOption "Grafana";
 
-    port = mkOption {
+    port = lib.mkOption {
       description = "Port.";
-      type = with types; port;
+      type = lib.types.port;
       default = 30101;
     };
 
-    domain = mkOption {
+    domain = lib.mkOption {
       description = "Domain name sans protocol scheme.";
-      type = with types; nullOr str;
+      type = with lib.types; nullOr str;
       default = "grafana.${config.networking.domain}";
     };
   };
@@ -31,7 +30,7 @@ in
     let
       db = "grafana";
     in
-    mkIf cfg.enable {
+    lib.mkIf cfg.enable {
       ark.directories = [ config.services.grafana.dataDir ];
 
       secrets = {
@@ -79,11 +78,11 @@ in
           enable = true;
 
           settings = {
-            server = with cfg; {
+            server = {
               protocol = "http";
               http_addr = "127.0.0.1";
-              http_port = port;
-              inherit domain;
+              http_port = cfg.port;
+              inherit (cfg) domain;
               enable_gzip = true;
             };
             database = {
@@ -95,7 +94,7 @@ in
             smtp = {
               enable = true;
               user = "azahi@shire.net";
-              host = my.domain.shire;
+              host = lib.my.domain.shire;
               password = "$__file{${config.secrets.grafana-smtp-password.path}}";
             };
             user = {
@@ -123,6 +122,6 @@ in
         };
       };
 
-      topology.nodes.${this.hostname}.services.grafana.info = mkForce cfg.domain;
+      topology.nodes.${this.hostname}.services.grafana.info = lib.mkForce cfg.domain;
     };
 }

Consider giving Nix/NixOS a try! <3