1 { config, lib, pkgs, ... }:
6 cfg = config.services.xandikos;
12 enable = mkEnableOption "Xandikos CalDAV and CardDAV server";
14 package = mkPackageOption pkgs "xandikos" { };
18 default = "localhost";
20 The IP address on which Xandikos will listen.
21 By default listens on localhost.
28 description = "The port of the Xandikos web application";
31 routePrefix = mkOption {
36 Useful when Xandikos is behind a reverse proxy.
40 extraOptions = mkOption {
42 type = types.listOf types.str;
43 example = literalExpression ''
46 "--current-user-principal user"
51 Extra command line arguments to pass to xandikos.
58 Configuration for nginx reverse proxy.
61 type = types.submodule {
67 Configure the nginx reverse proxy settings.
74 The hostname use to setup the virtualhost configuration
85 config = mkIf cfg.enable (
88 meta.maintainers = with lib.maintainers; [ _0x4A6F ];
90 systemd.services.xandikos = {
91 description = "A Simple Calendar and Contact Server";
92 after = [ "network.target" ];
93 wantedBy = [ "multi-user.target" ];
99 RuntimeDirectory = "xandikos";
100 StateDirectory = "xandikos";
101 StateDirectoryMode = "0700";
102 PrivateDevices = true;
104 CapabilityBoundingSet = "CAP_NET_RAW CAP_NET_ADMIN";
105 ProtectSystem = "strict";
108 ProtectKernelTunables = true;
109 ProtectKernelModules = true;
110 ProtectControlGroups = true;
111 RestrictAddressFamilies = "AF_INET AF_INET6 AF_UNIX AF_PACKET AF_NETLINK";
112 RestrictNamespaces = true;
113 LockPersonality = true;
114 MemoryDenyWriteExecute = true;
115 RestrictRealtime = true;
116 RestrictSUIDSGID = true;
118 ${cfg.package}/bin/xandikos \
119 --directory /var/lib/xandikos \
120 --listen-address ${cfg.address} \
121 --port ${toString cfg.port} \
122 --route-prefix ${cfg.routePrefix} \
123 ${lib.concatStringsSep " " cfg.extraOptions}
130 mkIf cfg.nginx.enable {
133 virtualHosts."${cfg.nginx.hostName}" = {
135 proxyPass = "http://${cfg.address}:${toString cfg.port}/";