blob: d6fabbcd47001dfa90f75bd1de9a79acaeceb760 (
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.services.radicale;
confFile = pkgs.writeText "radicale.conf" cfg.config;
# This enables us to default to version 2 while still not breaking configurations of people with version 1
defaultPackage = if versionAtLeast config.system.stateVersion "17.09" then {
pkg = pkgs.radicale2;
text = "pkgs.radicale2";
} else {
pkg = pkgs.radicale1;
text = "pkgs.radicale1";
};
in
{
options = {
services.radicale.enable = mkOption {
type = types.bool;
default = false;
description = ''
Enable Radicale CalDAV and CardDAV server.
'';
};
services.radicale.package = mkOption {
type = types.package;
default = defaultPackage.pkg;
defaultText = defaultPackage.text;
description = ''
Radicale package to use. This defaults to version 1.x if
<literal>system.stateVersion < 17.09</literal> and version 2.x
otherwise.
'';
};
services.radicale.config = mkOption {
type = types.string;
default = "";
description = ''
Radicale configuration, this will set the service
configuration file.
'';
};
services.radicale.extraArgs = mkOption {
type = types.listOf types.string;
default = [];
description = "Extra arguments passed to the Radicale daemon.";
};
};
config = mkIf cfg.enable {
environment.systemPackages = [ cfg.package ];
users.users = singleton
{ name = "radicale";
uid = config.ids.uids.radicale;
description = "radicale user";
home = "/var/lib/radicale";
createHome = true;
};
users.groups = singleton
{ name = "radicale";
gid = config.ids.gids.radicale;
};
systemd.services.radicale = {
description = "A Simple Calendar and Contact Server";
after = [ "network.target" ];
wantedBy = [ "multi-user.target" ];
serviceConfig = {
ExecStart = concatStringsSep " " ([
"${cfg.package}/bin/radicale" "-C" confFile
] ++ (
map escapeShellArg cfg.extraArgs
));
User = "radicale";
Group = "radicale";
};
};
};
meta.maintainers = with lib.maintainers; [ aneeshusa infinisil ];
}
|