zaphyra's git: tgcNUR

fork of https://git.transgirl.cafe/zaphoid/tgc-nix-user-repository

commit b57136bef0aa8e30f512b6555e3f2570f06edeac
parent 55820e390cad2f4aaa349ed6fdf89a4bf184ecce
Author: Katja Ramona Sophie Kwast (zaphyra) <git@zaphyra.eu>
Date: Wed, 20 Aug 2025 20:18:23 +0200

homeManagerModules/services: add `gomuks-web`
1 file changed, 54 insertions(+), 0 deletions(-)
A
homeManagerModules/services/gomuks-web/default.nix
|
54
++++++++++++++++++++++++++++++++++++++++++++++++++++++
diff --git a/homeManagerModules/services/gomuks-web/default.nix b/homeManagerModules/services/gomuks-web/default.nix
@@ -0,0 +1,54 @@
+{
+  config,
+  pkgs,
+  lib,
+  ...
+}:
+
+let
+  inherit (lib) types;
+  cfg = config.tgc.services.gomuks-web;
+
+in
+{
+
+  options.tgc.services.gomuks-web = {
+    enable = lib.mkEnableOption "A Matrix client written in Go.";
+    package = lib.mkPackageOption pkgs.tgc "gomuks-web" { };
+    listenAddress = lib.mkOption {
+      type = types.str;
+      default = "localhost:29325";
+      description = "Address to listen on.";
+    };
+    disableAuth = lib.mkOption {
+      type = types.bool;
+      default = false;
+      description = "Disable the basic-auth required to acces the web-interface.";
+    };
+  };
+
+  config = lib.mkIf cfg.enable {
+    systemd.user.services.gomuks-web = {
+      Unit = {
+        Description = "A Matrix client written in Go.";
+        After = [ "graphical-session-pre.target" ];
+        PartOf = [ "graphical-session.target" ];
+      };
+      Service = {
+        Restart = "on-failure";
+        RestartSec = 5;
+        ExecStartPre = pkgs.writeShellScript "gomuks-web-start-pre" ''
+          if [ -f ${config.xdg.configHome}/gomuks/config.yaml ]; then
+            ${lib.getExe pkgs.yq-go} -i '.web.listen_address = "${cfg.listenAddress}"' ${config.xdg.configHome}/gomuks/config.yaml
+          fi
+        '';
+        ExecStart = lib.concatStringsSep "" [
+          (lib.getExe cfg.package)
+          (if cfg.disableAuth then " --disable-auth" else "")
+        ];
+      };
+      Install.WantedBy = [ "graphical-session.target" ];
+    };
+  };
+
+}