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