1{config, lib, pkgs, ...}:
2
3with lib;
4
5let
6
7 cfg = config.services.radicale;
8
9 confFile = pkgs.writeText "radicale.conf" cfg.config;
10
11in
12
13{
14
15 options = {
16
17 services.radicale.enable = mkOption {
18 type = types.bool;
19 default = false;
20 description = ''
21 Enable Radicale CalDAV and CardDAV server
22 '';
23 };
24
25 services.radicale.config = mkOption {
26 type = types.string;
27 default = "";
28 description = ''
29 Radicale configuration, this will set the service
30 configuration file
31 '';
32 };
33 };
34
35 config = mkIf cfg.enable {
36 environment.systemPackages = [ pkgs.pythonPackages.radicale ];
37
38 systemd.services.radicale = {
39 description = "A Simple Calendar and Contact Server";
40 after = [ "network-interfaces.target" ];
41 wantedBy = [ "multi-user.target" ];
42 script = "${pkgs.pythonPackages.radicale}/bin/radicale -C ${confFile} -d";
43 serviceConfig.Type = "forking";
44 };
45 };
46}