2017-07-25 08:01:08 +01:00
|
|
|
{ config, lib, pkgs, ... }:
|
2014-05-27 21:27:31 +01:00
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
cfg = config.services.radicale;
|
|
|
|
|
|
|
|
confFile = pkgs.writeText "radicale.conf" cfg.config;
|
|
|
|
|
2017-07-25 08:01:08 +01:00
|
|
|
# This enables us to default to version 2 while still not breaking configurations of people with version 1
|
2018-07-25 21:22:54 +01:00
|
|
|
defaultPackage = if versionAtLeast config.system.stateVersion "17.09" then {
|
2017-07-25 08:01:08 +01:00
|
|
|
pkg = pkgs.radicale2;
|
|
|
|
text = "pkgs.radicale2";
|
|
|
|
} else {
|
|
|
|
pkg = pkgs.radicale1;
|
|
|
|
text = "pkgs.radicale1";
|
|
|
|
};
|
2014-05-27 21:27:31 +01:00
|
|
|
in
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
options = {
|
|
|
|
services.radicale.enable = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
|
|
|
description = ''
|
2017-07-25 08:01:08 +01:00
|
|
|
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
|
2018-07-25 21:22:54 +01:00
|
|
|
<literal>system.stateVersion < 17.09</literal> and version 2.x
|
2017-07-25 08:01:08 +01:00
|
|
|
otherwise.
|
2014-05-27 21:27:31 +01:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
services.radicale.config = mkOption {
|
2019-08-08 21:48:27 +01:00
|
|
|
type = types.str;
|
2014-05-27 21:27:31 +01:00
|
|
|
default = "";
|
|
|
|
description = ''
|
|
|
|
Radicale configuration, this will set the service
|
2017-07-25 08:01:08 +01:00
|
|
|
configuration file.
|
2014-05-27 21:27:31 +01:00
|
|
|
'';
|
2017-07-25 08:01:08 +01:00
|
|
|
};
|
2017-09-18 06:11:23 +01:00
|
|
|
|
|
|
|
services.radicale.extraArgs = mkOption {
|
2019-08-08 21:48:27 +01:00
|
|
|
type = types.listOf types.str;
|
2017-09-18 06:11:23 +01:00
|
|
|
default = [];
|
|
|
|
description = "Extra arguments passed to the Radicale daemon.";
|
|
|
|
};
|
2014-05-27 21:27:31 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
2017-07-25 08:01:08 +01:00
|
|
|
environment.systemPackages = [ cfg.package ];
|
2014-05-27 21:27:31 +01:00
|
|
|
|
2019-09-14 18:51:29 +01:00
|
|
|
users.users.radicale =
|
|
|
|
{ uid = config.ids.uids.radicale;
|
2016-03-20 14:25:02 +00:00
|
|
|
description = "radicale user";
|
|
|
|
home = "/var/lib/radicale";
|
|
|
|
createHome = true;
|
|
|
|
};
|
|
|
|
|
2019-09-14 18:51:29 +01:00
|
|
|
users.groups.radicale =
|
|
|
|
{ gid = config.ids.gids.radicale; };
|
2016-03-20 14:25:02 +00:00
|
|
|
|
2016-01-06 06:50:18 +00:00
|
|
|
systemd.services.radicale = {
|
2014-05-27 21:27:31 +01:00
|
|
|
description = "A Simple Calendar and Contact Server";
|
2016-09-10 19:17:43 +01:00
|
|
|
after = [ "network.target" ];
|
2016-01-06 06:50:18 +00:00
|
|
|
wantedBy = [ "multi-user.target" ];
|
2017-07-25 08:01:08 +01:00
|
|
|
serviceConfig = {
|
2017-09-18 06:11:23 +01:00
|
|
|
ExecStart = concatStringsSep " " ([
|
|
|
|
"${cfg.package}/bin/radicale" "-C" confFile
|
|
|
|
] ++ (
|
|
|
|
map escapeShellArg cfg.extraArgs
|
|
|
|
));
|
2017-07-25 08:01:08 +01:00
|
|
|
User = "radicale";
|
|
|
|
Group = "radicale";
|
|
|
|
};
|
2014-05-27 21:27:31 +01:00
|
|
|
};
|
|
|
|
};
|
2017-03-20 16:13:27 +00:00
|
|
|
|
2017-07-25 08:01:08 +01:00
|
|
|
meta.maintainers = with lib.maintainers; [ aneeshusa infinisil ];
|
2014-05-27 21:27:31 +01:00
|
|
|
}
|