summary refs log tree commit diff stats
path: root/system/linde.nix
diff options
context:
space:
mode:
authorAlan Pearce2024-06-29 14:57:42 +0200
committerAlan Pearce2024-06-29 14:57:42 +0200
commitfdb646b04e0e7fc49b9f20ae4f54e1d41f582f9d (patch)
treefa0526a1158b7451baa10f4387279e684eac8e83 /system/linde.nix
parentabfb9a47ca8ea24287a94e00340ff193badf5327 (diff)
downloadnixfiles-fdb646b04e0e7fc49b9f20ae4f54e1d41f582f9d.tar.lz
nixfiles-fdb646b04e0e7fc49b9f20ae4f54e1d41f582f9d.tar.zst
nixfiles-fdb646b04e0e7fc49b9f20ae4f54e1d41f582f9d.zip
linde: set up goatcounter
Diffstat (limited to 'system/linde.nix')
-rw-r--r--system/linde.nix26
1 files changed, 26 insertions, 0 deletions
diff --git a/system/linde.nix b/system/linde.nix
index 2ae0b714..3a4b66ec 100644
--- a/system/linde.nix
+++ b/system/linde.nix
@@ -22,6 +22,7 @@ in
   imports =
     [
       <personal/modules/nixos/laminar.nix>
+      <personal/modules/nixos/goatcounter.nix>
       <home-manager/nixos>
       <agenix/modules/age.nix>
       <searchix/nix/modules>
@@ -344,6 +345,17 @@ in
   # (e.g. man configuration.nix or on https://nixos.org/nixos/options.html).
   system.stateVersion = "23.05"; # Did you read the comment?
 
+  services.goatcounter = {
+    enable = true;
+    listenAddress = "localhost";
+    port = 8082;
+    package = (import <personal> { inherit pkgs; }).goatcounter;
+    settings = {
+      tls = "proxy";
+      websocket = true;
+    };
+  };
+
   services.powerdns =
     let
       inherit (lib.lists) flatten;
@@ -597,6 +609,9 @@ in
       reloadServices = map (x: "kresd@${toString x}") (range 1 config.services.kresd.instances);
       group = "knot-resolver";
     };
+    certs."stats.alanpearce.eu" = {
+      extraDomainNames = [ "*.stats.alanpearce.eu" ];
+    };
   };
   users.groups.acme.members = [
     "caddy"
@@ -729,6 +744,17 @@ in
               reverse_proxy ${srv.settings.bindHTTP}
             '';
           };
+        "stats.alanpearce.eu" =
+          let
+            srv = config.services.goatcounter;
+          in
+          {
+            useACMEHost = "stats.alanpearce.eu";
+            serverAliases = [ "*.stats.alanpearce.eu" ];
+            extraConfig = ''
+              reverse_proxy ${srv.listenAddress}:${toString srv.port}
+            '';
+          };
       };
   };
   systemd.services.caddy.serviceConfig = {