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