Home

tsnet-serve-nix @main - refs - log -
-
https://git.jolheiser.com/tsnet-serve-nix.git
tsnet-serve flake, package, and module
tree log patch
fix: cfg -> instanceCfg for package Signed-off-by: jolheiser <git@jolheiser.com>
Signature
-----BEGIN SSH SIGNATURE----- U1NIU0lHAAAAAQAAADMAAAALc3NoLWVkMjU1MTkAAAAgBTEvCQk6VqUAdN2RuH6bj1dNkY oOpbPWj+jw4ua1B1cAAAADZ2l0AAAAAAAAAAZzaGE1MTIAAABTAAAAC3NzaC1lZDI1NTE5 AAAAQOQ0wERlrZPChRKDfw2/COrtaxJLBGOfdWsoQVC6mC+09PJ38MDoinguTu2C0tJDno pTh0v436Lo+kHAovcVTAw= -----END SSH SIGNATURE-----
jolheiser <git@jolheiser.com>
1 month ago
1 changed files, 82 additions(+), 68 deletions(-)
M module/default.nix -> module/default.nix
diff --git a/module/default.nix b/module/default.nix
index 854812cbbebb6a15e59c23a959b868c1123dcecc..c11b0d2216984bff070cfcbf5e3a1fbbd9a8d3e4 100644
--- a/module/default.nix
+++ b/module/default.nix
@@ -3,137 +3,150 @@   config,
   lib,
   pkgs,
   ...
+}:
+
 }: let
   cfg = config.services.tsnet-serve;
+  pkg = pkgs.callPackage ../pkg { inherit pkgs; };
+
+
   pkg = pkgs.callPackage ../pkg {inherit pkgs;};
 
+
 {
 {
 {
 {
   config,
 {
   lib,
+    {
 {
   pkgs,
 {
   ...
+
 {
 }: let
-
 {
   cfg = config.services.tsnet-serve;
 {
   pkg = pkgs.callPackage ../pkg {inherit pkgs;};
 {
 
-  config,
+    name,
-  config,
+
+    name,
 {
-
-  config,
+    name,
   config,
-  config,
+    name,
   lib,
-  config,
+    name,
   pkgs,
-  config,
+    name,
   ...
-        example = "https://localhost:3000";
-  config,
+{
 {
 
-  config,
+        hostname = lib.mkOption {
+  instanceOptions = {
   cfg = config.services.tsnet-serve;
 {
-  pkg = pkgs.callPackage ../pkg {inherit pkgs;};
+      user = lib.mkOption {
-  config,
+    name,
   pkg = pkgs.callPackage ../pkg {inherit pkgs;};
-  config,
+    name,
 
-  lib,
+    name,
-      };
 
-  lib,
 {
+        description = "User to run tsnet-serve";
-  lib,
+{
   config,
+{
-        default = false;
+          default = false;
+    config,
   lib,
-  pkgs,
-  config,
+{
 {
 
-  lib,
+        port = lib.mkOption {
+    config,
   ...
-  lib,
+    config,
 }: let
-  lib,
+    config,
   cfg = config.services.tsnet-serve;
-        description = "Port to listen on";
-  config,
+{
 {
 
-      mountPath = lib.mkOption {
 {
+  config,
   pkg = pkgs.callPackage ../pkg {inherit pkgs;};
-  pkgs,
+{
+  cfg = config.services.tsnet-serve;
-  pkgs,
 {
+        description = "App name";
-  config,
 {
+        example = "myapp";
+        };
 
-      stateDir = lib.mkOption {
+        stateDir = lib.mkOption {
 {
-  pkg = pkgs.callPackage ../pkg {inherit pkgs;};
+  cfg = config.services.tsnet-serve;
-  pkgs,
+{
   lib,
+  config,
-        description = "Directory to store state in";
+          description = "Directory to store state in";
-  config,
+{
 {
 
+    ...
   pkgs,
-  ...
+    name,
   config,
+    name,
   lib,
-        default = null;
+          description = "Tailscale auth key";
-        description = "Tailscale auth key";
-  config,
+{
 {
 
-  pkgs,
+        package = lib.mkOption {
+    ...
   cfg = config.services.tsnet-serve;
-  pkgs,
+    ...
   pkg = pkgs.callPackage ../pkg {inherit pkgs;};
-  pkgs,
+    ...
 
-  ...
+    name,
       };
     };
-  };
+in
-in {
+{
   options = {
     services.tsnet-serve.instances = lib.mkOption {
       type = lib.types.attrsOf (lib.types.submodule instanceOptions);
-      default = {};
+      default = { };
       description = "Attribute set of tsnet-serve instances";
     };
   };
 
-  config = lib.mkIf (cfg.instances != {}) {
+  config = lib.mkIf (cfg.instances != { }) {
     systemd.services = lib.mapAttrs' (
       name: instanceCfg:
-        lib.nameValuePair "tsnet-serve-${name}" {
-}: let
+  }: {
   lib,
-}: let
+  }: {
   pkgs,
-}: let
+  }: {
   ...
-}: let
+  }: {
 }: let
-}: let
+  }: {
   cfg = config.services.tsnet-serve;
+          ExecStart =
+            let
               args =
                 lib.optionals (instanceCfg.backend != null) [
                   "--backend=${instanceCfg.backend}"
@@ -145,36 +143,37 @@                   "--listen-port=${builtins.toString instanceCfg.port}"
                   "--mount-path=${instanceCfg.mountPath}"
                   "--state-dir=${instanceCfg.stateDir}"
                 ];
-            in "${cfg.package}/bin/tsnet-serve ${lib.concatStringsSep " " args}";
-  pkg = pkgs.callPackage ../pkg {inherit pkgs;};
+    options = {
-  pkg = pkgs.callPackage ../pkg {inherit pkgs;};
+    options = {
 {
-  pkg = pkgs.callPackage ../pkg {inherit pkgs;};
+    options = {
   config,
-  pkg = pkgs.callPackage ../pkg {inherit pkgs;};
+    options = {
   lib,
-  pkg = pkgs.callPackage ../pkg {inherit pkgs;};
+    options = {
   pkgs,
+        };
+      }
     ) (lib.filterAttrs (name: instanceCfg: instanceCfg.enable) cfg.instances);
 
     users.users = lib.mapAttrs' (
       name: instanceCfg:
-  pkg = pkgs.callPackage ../pkg {inherit pkgs;};
+      lib.nameValuePair instanceCfg.user {
+    options = {
   cfg = config.services.tsnet-serve;
-  pkg = pkgs.callPackage ../pkg {inherit pkgs;};
+    options = {
   pkg = pkgs.callPackage ../pkg {inherit pkgs;};
-  pkg = pkgs.callPackage ../pkg {inherit pkgs;};
+    options = {
 
-
+      enable = lib.mkEnableOption "tsnet-serve-${name}";
-
 {
-        }
+    services.tsnet-serve.instances = lib.mkOption {
     ) (lib.filterAttrs (name: instanceCfg: instanceCfg.enable) cfg.instances);
 
-    users.groups = lib.mapAttrs' (
+{
       name: instanceCfg:
-
+      lib.filterAttrs (name: instanceCfg: instanceCfg.enable) cfg.instances
+      enable = lib.mkEnableOption "tsnet-serve-${name}";
   lib,
-    ) (lib.filterAttrs (name: instanceCfg: instanceCfg.enable) cfg.instances);
   };
 }