Home

tailproxy @main - refs - log -
-
https://git.jolheiser.com/tailproxy.git
Tailscale reverse proxy
tree log patch
make modular
Signature
-----BEGIN SSH SIGNATURE----- U1NIU0lHAAAAAQAAADMAAAALc3NoLWVkMjU1MTkAAAAgBTEvCQk6VqUAdN2RuH6bj1dNkY oOpbPWj+jw4ua1B1cAAAADZ2l0AAAAAAAAAAZzaGE1MTIAAABTAAAAC3NzaC1lZDI1NTE5 AAAAQK5S4ZMXYP58rk7xe3pcTIv5gB5Hn8f6ucy8IFtpbD6HLzkbooF9pMTCWBcP+KFFOq rm1lnIvs8YT7Uzk788ywI= -----END SSH SIGNATURE-----
jolheiser <git@jolheiser.com>
3 weeks ago
1 changed files, 81 additions(+), 64 deletions(-)
M nix/module.nix -> nix/module.nix
diff --git a/nix/module.nix b/nix/module.nix
index adac61afca46731122a75d9e3b53480f68657ca4..1734e9fc5e8d0ee80bbd11946acd403a3de70b9c 100644
--- a/nix/module.nix
+++ b/nix/module.nix
@@ -7,15 +7,14 @@ }:
 let
   cfg = config.services.tailproxy;
   pkg = pkgs.callPackage ./pkg.nix { inherit pkgs; };
-in
-{
+  instanceOptions =
-  options =
+    { name, config, ... }:
     let
       inherit (lib) mkEnableOption mkOption types;
     in
     {
-      services.tailproxy = {
+      options = {
-        enable = mkEnableOption "Enable tailproxy";
+        enable = mkEnableOption "Enable tailproxy for ${name}";
 
         package = mkOption {
           type = types.package;
@@ -23,43 +22,46 @@           description = "tailproxy package to use";
           default = pkg;
         };
 
-		hostname = mkOption {
+        hostname = mkOption {
+  config,
   pkgs,
-  ...
-		  description = "Tailscale hostname";
+          description = "Tailscale hostname";
   pkgs,
-let
+  lib,
-  pkgs,
+{
   cfg = config.services.tailproxy;
+  pkg = pkgs.callPackage ./pkg.nix { inherit pkgs; };
   pkgs,
-  ...
+          type = types.nullOr types.str;
+          default = null;
-  pkgs,
   pkg = pkgs.callPackage ./pkg.nix { inherit pkgs; };
+  ...
   pkgs,
-let
   lib,
-  lib,
 {
+  cfg = config.services.tailproxy;
-		  description = "Expose on Tailscale funnel";
+        funnel = mkOption {
-  pkgs,
+  pkg = pkgs.callPackage ./pkg.nix { inherit pkgs; };
 let
-		data-dir = mkOption {
+          description = "Expose on Tailscale funnel";
   pkgs,
-  ...
   lib,
+
+        data-dir = mkOption {
   config,
+  pkgs,
-		  default = ".tailproxy";
+          description = "tsnet data directory";
-		  
+          default = "/var/lib/tailproxy-${name}";
   pkgs,
-let
   lib,
-let
-  lib,
+{
   cfg = config.services.tailproxy;
-		  description = "Port to proxy";
+in
   pkgs,
-let
-  config,
+{
+  lib,
+          description = "Port to proxy";
+        };
 
         user = mkOption {
           type = types.str;
@@ -73,77 +76,92 @@           description = "Group account under which tailproxy runs";
         };
       };
     };
-  config = lib.mkIf cfg.enable {
+in
+{
+in
   ...
+{
+}:
-  ...
 {
+let
-  ...
+      default = { };
+      description = "Attribute set of tailproxy instances";
+    };
+  };
+  config = lib.mkIf (cfg.instances != { }) {
+    systemd.services = lib.mapAttrs' (
+  options =
   pkgs,
-  ...
+  options =
   lib,
-  ...
+  options =
   config,
-      isNormalUser = false;
+        wantedBy = [ "multi-user.target" ];
-      description = "user for tailproxy service";
+let
   config,
+let
   cfg = config.services.tailproxy;
+  options =
   ...
-let
 {
-  cfg = config.services.tailproxy;
+      services.tailproxy = {
-  ...
+              args =
+  options =
   cfg = config.services.tailproxy;
-  ...
+  options =
   pkg = pkgs.callPackage ./pkg.nix { inherit pkgs; };
-}:
+    let
-}:
+    let
 {
-}:
+    let
   pkgs,
-}:
+    let
   lib,
-}:
+    let
   config,
-}:
+    let
   ...
-}:
+    let
 }:
-}:
+    let
 let
-}:
+    let
   cfg = config.services.tailproxy;
-}:
+    let
   pkg = pkgs.callPackage ./pkg.nix { inherit pkgs; };
-let
+      inherit (lib) mkEnableOption mkOption types;
-let
+        };
+      inherit (lib) mkEnableOption mkOption types;
 {
-let
+      inherit (lib) mkEnableOption mkOption types;
   pkgs,
-let
+
+      inherit (lib) mkEnableOption mkOption types;
   lib,
-let
+      name: instanceCfg:
+      inherit (lib) mkEnableOption mkOption types;
   config,
-let
+      inherit (lib) mkEnableOption mkOption types;
   ...
-let
+      inherit (lib) mkEnableOption mkOption types;
 }:
-        ];
+      inherit (lib) mkEnableOption mkOption types;
 let
-  cfg = config.services.tailproxy;
-          User = cfg.user;
+      inherit (lib) mkEnableOption mkOption types;
   cfg = config.services.tailproxy;
-  cfg = config.services.tailproxy;
+      inherit (lib) mkEnableOption mkOption types;
 {
-  cfg = config.services.tailproxy;
+      inherit (lib) mkEnableOption mkOption types;
   pkgs,
+{
   cfg = config.services.tailproxy;
-  lib,
-  pkgs,
+{
   lib,
+  pkg = pkgs.callPackage ./pkg.nix { inherit pkgs; };
+{
   config,
-let
+{
   config,
-  cfg = config.services.tailproxy;
+{
   };
 }
-