summaryrefslogtreecommitdiff
path: root/home/pim/dav.nix
blob: c19b2edd6c765a773109f2fce90c9b14b54bf0f2 (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
46
47
48
49
50
{ config, lib, pkgs, ... }:
with lib; let
  cfg = config.local.dav;
in
{
  options.local.dav = with types; {
    enable = mkEnableOption "Web/Card/CalDAV";
  };

  config = mkIf cfg.enable {
    systemd.user = {
      services.xandikos = {
        Unit = {
          Description = "Xandikos CalDAV/CardDAV server";
        };

        Service = {
          ExecStart = escapeShellArgs [
            (getExe pkgs.xandikos)
            "-d"
            "${config.home.homeDirectory}/dav"
            "--route-prefix"
            "/${config.home.username}/dav"
            "--current-user-principal"
            "/user/"
            # Hacerlo fallar si no agarra systemd socket activation por cualquier motivo
            "-p"
            "1"
          ];

          Type = "simple";
        };
      };

      sockets.xandikos = {
        Unit = {
          Description = "Xandikos socket";
        };

        Socket = {
          ListenStream = "/run/host-www/ale/dav.sock";
        };

        Install = {
          WantedBy = [ "sockets.target" ];
        };
      };
    };
  };
}