From c153a351659e4596acfc31f00bf594343cbfcd68 Mon Sep 17 00:00:00 2001 From: Benedikt Peetz Date: Thu, 30 Jul 2026 14:05:39 +0200 Subject: modules: Use namespaces That might make it easier in the future to merge different server configs together (and thusly facilitate code-reuse.). --- modules/vhack/ta/taskchampion-sync/module.nix | 66 +++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 modules/vhack/ta/taskchampion-sync/module.nix (limited to 'modules/vhack/ta/taskchampion-sync') diff --git a/modules/vhack/ta/taskchampion-sync/module.nix b/modules/vhack/ta/taskchampion-sync/module.nix new file mode 100644 index 0000000..a7cba30 --- /dev/null +++ b/modules/vhack/ta/taskchampion-sync/module.nix @@ -0,0 +1,66 @@ +{ + config, + lib, + ... +}: let + cfg = config.vhack.taskchampion-sync; + dataDirectory = "/var/lib/taskchampion-sync-server"; +in { + options.vhack.taskchampion-sync = { + enable = lib.mkEnableOption "taskchampion-sync"; + + fqdn = lib.mkOption { + description = "The fully qualified domain name of this instance."; + type = lib.types.str; + example = "task-sync.tw.online"; + }; + }; + + config = lib.mkIf cfg.enable { + users = { + users.taskchampion = { + uid = config.vhack.constants.ids.uids.taskchampion; + group = "taskchampion"; + }; + groups.taskchampion.gid = config.vhack.constants.ids.uids.taskchampion; + }; + + vhack = { + persist.directories = [ + { + directory = dataDirectory; + user = "taskchampion"; + group = "taskchampion"; + mode = "0700"; + } + ]; + nginx.enable = true; + }; + + systemd.services.taskchampion-sync-server = { + serviceConfig = { + # The upstream service uses DynamicUsers, which currently poses issues to our + # directory persisting strategy. + User = "taskchampion"; + Group = "taskchampion"; + DynamicUser = lib.mkForce false; + }; + }; + + services = { + taskchampion-sync-server = { + enable = true; + dataDir = dataDirectory; + }; + + nginx.virtualHosts."${cfg.fqdn}" = { + locations."/" = { + proxyPass = "http://127.0.0.1:${toString config.services.taskchampion-sync-server.port}"; + recommendedProxySettings = true; + }; + enableACME = true; + forceSSL = true; + }; + }; + }; +} -- cgit v1.3.1