about summary refs log tree commit diff stats
path: root/modules/by-name/ta/taskchampion-sync/module.nix
blob: a722883622fa5161abd22b6193a1a9d7f16c4f6c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
{
  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;
      groups.taskchampion.gid = config.vhack.constants.ids.uids.taskchampion;
    };

    vhack = {
      persist.directories = [
        {
          directory = dataDirectory;
          user = "taskchampion";
          group = "taskchampion";
          mode = "0700";
        }
      ];
      nginx.enable = true;
    };

    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;
      };
    };
  };
}