summary refs log tree commit diff
path: root/nixos/modules/services/networking/radicale.nix
blob: 4b77ef22ac12c296934976083529418b772b3b69 (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
{config, lib, pkgs, ...}:

with lib;

let

  cfg = config.services.radicale;

  confFile = pkgs.writeText "radicale.conf" cfg.config;

in

{

  options = {

    services.radicale.enable = mkOption {
      type = types.bool;
      default = false;
      description = ''
          Enable Radicale CalDAV and CardDAV server
      '';
    };

    services.radicale.config = mkOption {
      type = types.string;
      default = "";
      description = ''
        Radicale configuration, this will set the service
        configuration file
      '';
      };
  };

  config = mkIf cfg.enable {
    environment.systemPackages = [ pkgs.pythonPackages.radicale ];

    systemd.services.radicale = {
      description = "A Simple Calendar and Contact Server";
      after = [ "network-interfaces.target" ];
      wantedBy = [ "multi-user.target" ];
      script = "${pkgs.pythonPackages.radicale}/bin/radicale -C ${confFile} -d";
      serviceConfig.Type = "forking";
    };
  };
}