summary refs log tree commit diff stats
path: root/modules/nixos/vhack/etesync/default.nix
blob: 0f6c5653dc80a97b80a42a765749f29912a4652d (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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
{
  config,
  lib,
  ...
}: let
  cfg = config.vhack.etesync;
in {
  options.vhack.etesync = {
    enable = lib.mkEnableOption ''
      a secure, end-to-end encrypted, and privacy respecting sync for your contacts, calendars, tasks and notes.
    '';
  };

  config = lib.mkIf cfg.enable {
    services.etebase-server = {
      enable = true;
      port = 8001;
      settings = {
        global.secret_file = "${config.age.secrets.etebase-server.path}";
        allowed_hosts = {
          allowed_host1 = "etebase.vhack.eu";
          allowed_host2 = "dav.vhack.eu";
        };
      };
    };

    age.secrets.etebase-server = {
      file = ./secret_file.age;
      mode = "700";
      owner = "etebase-server";
      group = "etebase-server";
    };

    environment.persistence."/srv".directories = [
      {
        directory = "/var/lib/etebase-server";
        user = "etebase-server";
        group = "etebase-server";
        mode = "0700";
      }
    ];

    services.nginx = {
      enable = true;
      recommendedTlsSettings = true;
      recommendedOptimisation = true;
      recommendedGzipSettings = true;
      recommendedProxySettings = true;

      virtualHosts = {
        "etebase.vhack.eu" = {
          enableACME = true;
          forceSSL = true;

          locations = {
            # TODO: Maybe fix permissions to use pregenerated static files which would
            # improve performance.
            #"/static" = {
            #  root = config.services.etebase-server.settings.global.static_root;
            #};
            "/" = {
              proxyPass = "http://127.0.0.1:${builtins.toString config.services.etebase-server.port}";
            };
          };
          serverAliases = [
            "dav.vhack.eu"
          ];
        };
      };
    };
  };
}