Commit 70be86a

HPCesia <me@hpcesia.com>
2026-07-21 14:36:46
Add Headplane service
1 parent a780d80
modules/hosts/hyacine/services/services.nix
@@ -10,6 +10,11 @@
       domains = ["goatcounter.hpcesia.com"];
     };
 
+    services.headplane = {
+      domain = "gate.trin.one";
+      port = 3466;
+      cookieSecretFileAged = ./headplane-cookie-secret.age;
+    };
     services.headscale = {
       domain = "gate.trin.one";
       port = 3465;
@@ -37,6 +42,7 @@
 
       den.aspects.services.artalk
       den.aspects.services.goatcounter
+      den.aspects.services.headplane
       den.aspects.services.headscale
       den.aspects.services.vaultwarden
       den.aspects.services.wakapi
modules/services/headplane.nix
@@ -0,0 +1,70 @@
+{lib, ...}: {
+  den.aspects.services.headplane = {
+    settings = {
+      domain = lib.mkOption {
+        type = lib.types.nullOr lib.types.str;
+        default = null;
+      };
+      port = lib.mkOption {
+        type = lib.types.port;
+        default = 8081;
+      };
+      cookieSecretFileAged = lib.mkOption {
+        type = lib.types.path;
+        description = "An age encypted file containing the cookie secret. The secret must be exactly 32 characters long.";
+      };
+    };
+
+    persist = {
+      directories = [
+        {
+          directory = "/var/lib/headplane";
+          user = "headscale";
+          group = "headscale";
+          mode = "0700";
+        }
+      ];
+    };
+
+    reverseProxy = {host, ...}: let
+      cfg = host.settings.services.headplane;
+    in {
+      ${cfg.domain} = {
+        port = cfg.port;
+        path = "/admin";
+        stripPath = false;
+      };
+    };
+
+    nixos = {
+      host,
+      config,
+      ...
+    }: let
+      cfg = host.settings.services.headplane;
+    in {
+      services.headplane = {
+        enable = true;
+
+        settings = {
+          headscale = {
+            config_path = "/var/lib/headscale/config.yaml";
+            dns_records_path = "/var/lib/headscale/dns-records.json";
+          };
+          server = {
+            base_url = "https://${cfg.domain}/admin/oidc/callback";
+            port = cfg.port;
+            cookie_secret_path = config.vaultix.secrets.headplane-cookie-secret.path;
+          };
+        };
+      };
+
+      vaultix.secrets.headplane-cookie-secret = {
+        file = cfg.cookieSecretFileAged;
+        owner = config.services.headscale.user;
+        group = config.services.headscale.group;
+        mode = "0400";
+      };
+    };
+  };
+}
modules/services/headscale.nix
@@ -181,6 +181,7 @@
           exec ${lib.getExe hsCfg.package} serve --config ${mutableConfig}
         '';
       };
+
       vaultix.templates.headscale-env =
         lib.mkIf (hostAddr.ipv4.secret.name != null || hostAddr.ipv6.secret.name != null)
         {
secrets/cache/hyacine/efec40c9d2327ec91ddf86ab8a5449b0ad794a99d4179a154cb7ad0f2cd1457d
Binary file