summaryrefslogtreecommitdiff
path: root/modules/nixosModules/server/radicale.nix
blob: 7f62b70362c12e64d96a56c6e67a67cb410b4486 (plain)
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
{
  self,
  lib,
  ...
}: {
  flake.nixosModules.radicale = {config, ...}: let
    cfg = config.hostOptions.server;
  in {
    imports = [
      self.nixosModules.hostOptions
      self.nixosModules.nginx
    ];

    services.radicale = {
      enable = true;
      settings = {
        server.hosts = ["127.0.0.1:5232"];
        auth = {
          type = "htpasswd";
          htpasswd_filename = "${cfg.dataPath}/radicale/users";
          htpasswd_encryption = "autodetect";
        };
        storage.filesystem_folder = "${cfg.dataPath}/radicale/calendars/";
      };
    };

    users.users.radicale = {
      isSystemUser = true;
      group = "radicale";
    };
    users.groups.radicale = {};
    systemd.services.radicale.serviceConfig = {
      DynamicUser = lib.mkForce false;
      User = lib.mkForce "radicale";
      Group = lib.mkForce "radicale";
      ReadWritePaths = ["${cfg.dataPath}/arr/radicale/"];
    };

    services.nginx.virtualHosts."radicale.${cfg.domain}" = {
      enableACME = true;
      forceSSL = true;
      locations."/".proxyPass = "http://127.0.0.1:5232";
    };
  };
}