1 { config, lib, pkgs, ... }:
6 cfg = config.services.xandikos;
12 enable = mkEnableOption (lib.mdDoc "Xandikos CalDAV and CardDAV server");
16 default = pkgs.xandikos;
17 defaultText = literalExpression "pkgs.xandikos";
18 description = lib.mdDoc "The Xandikos package to use.";
23 default = "localhost";
24 description = lib.mdDoc ''
25 The IP address on which Xandikos will listen.
26 By default listens on localhost.
33 description = lib.mdDoc "The port of the Xandikos web application";
36 routePrefix = mkOption {
39 description = lib.mdDoc ''
41 Useful when Xandikos is behind a reverse proxy.
45 extraOptions = mkOption {
47 type = types.listOf types.str;
48 example = literalExpression ''
51 "--current-user-principal user"
55 description = lib.mdDoc ''
56 Extra command line arguments to pass to xandikos.
62 description = lib.mdDoc ''
63 Configuration for nginx reverse proxy.
66 type = types.submodule {
71 description = lib.mdDoc ''
72 Configure the nginx reverse proxy settings.
78 description = lib.mdDoc ''
79 The hostname use to setup the virtualhost configuration
90 config = mkIf cfg.enable (
93 meta.maintainers = with lib.maintainers; [ _0x4A6F ];
95 systemd.services.xandikos = {
96 description = "A Simple Calendar and Contact Server";
97 after = [ "network.target" ];
98 wantedBy = [ "multi-user.target" ];
104 RuntimeDirectory = "xandikos";
105 StateDirectory = "xandikos";
106 StateDirectoryMode = "0700";
107 PrivateDevices = true;
109 CapabilityBoundingSet = "CAP_NET_RAW CAP_NET_ADMIN";
110 ProtectSystem = "strict";
113 ProtectKernelTunables = true;
114 ProtectKernelModules = true;
115 ProtectControlGroups = true;
116 RestrictAddressFamilies = "AF_INET AF_INET6 AF_UNIX AF_PACKET AF_NETLINK";
117 RestrictNamespaces = true;
118 LockPersonality = true;
119 MemoryDenyWriteExecute = true;
120 RestrictRealtime = true;
121 RestrictSUIDSGID = true;
123 ${cfg.package}/bin/xandikos \
124 --directory /var/lib/xandikos \
125 --listen-address ${cfg.address} \
126 --port ${toString cfg.port} \
127 --route-prefix ${cfg.routePrefix} \
128 ${lib.concatStringsSep " " cfg.extraOptions}
135 mkIf cfg.nginx.enable {
138 virtualHosts."${cfg.nginx.hostName}" = {
140 proxyPass = "http://${cfg.address}:${toString cfg.port}/";