about summary refs log tree commit diff
path: root/modules/nixos/plausible.nix
diff options
context:
space:
mode:
authorAzat Bahawi <azat@bahawi.net>2024-03-31 21:29:27 +0300
committerAzat Bahawi <azat@bahawi.net>2024-03-31 21:29:27 +0300
commit9a5427e3a0c0ccf2a82dc503149a26b23fbd6004 (patch)
treef28beec29deeea36038615a8fb98a810891940b5 /modules/nixos/plausible.nix
parent2024-03-19 (diff)
2024-03-31
Diffstat (limited to '')
-rw-r--r--modules/nixos/plausible.nix27
1 files changed, 16 insertions, 11 deletions
diff --git a/modules/nixos/plausible.nix b/modules/nixos/plausible.nix
index 8de54d2..d63e3ab 100644
--- a/modules/nixos/plausible.nix
+++ b/modules/nixos/plausible.nix
@@ -4,9 +4,11 @@
   lib,
   ...
 }:
-with lib; let
+with lib;
+let
   cfg = config.nixfiles.modules.plausible;
-in {
+in
+{
   options.nixfiles.modules.plausible = {
     enable = mkEnableOption "Plausible Analytics";
 
@@ -23,15 +25,18 @@ in {
     };
   };
 
-  config = let
-    db = "plausible";
-  in
+  config =
+    let
+      db = "plausible";
+    in
     mkIf cfg.enable {
       _module.args.libPlausible = {
-        htmlPlausibleScript = {
-          domain ? "$host",
-          src ? "https://${cfg.domain}/js/script.js",
-        }: ''<script defer data-domain="${domain}" src="${src}"></script>'';
+        htmlPlausibleScript =
+          {
+            domain ? "$host",
+            src ? "https://${cfg.domain}/js/script.js",
+          }:
+          ''<script defer data-domain="${domain}" src="${src}"></script>'';
       };
 
       secrets = {
@@ -43,7 +48,7 @@ in {
       nixfiles.modules = {
         nginx = {
           enable = true;
-          upstreams.plausible.servers."127.0.0.1:${toString cfg.port}" = {};
+          upstreams.plausible.servers."127.0.0.1:${toString cfg.port}" = { };
           virtualHosts.${cfg.domain}.locations."/" = {
             proxyPass = "http://plausible";
             proxyWebsockets = true;
@@ -62,7 +67,7 @@ in {
       };
 
       services.postgresql = {
-        ensureDatabases = [db];
+        ensureDatabases = [ db ];
         ensureUsers = [
           {
             name = db;

Consider giving Nix/NixOS a try! <3