{ tgcMaintainers, tgcFlake, ... }: { config, pkgs, lib, ... }: let inherit (lib) types; cfg = config.tgc.services.gomuks-web; in { meta.maintainers = [ tgcMaintainers.zaphyra ]; options.tgc.services.gomuks-web = { enable = lib.mkEnableOption "A Matrix client written in Go."; package = lib.mkPackageOption tgcFlake.packages.${pkgs.system} "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" ]; }; }; }