2025-01-04 10:22:05 +00:00
|
|
|
{
|
|
|
|
lib,
|
|
|
|
pkgs,
|
|
|
|
config,
|
|
|
|
nglib,
|
|
|
|
...
|
|
|
|
}: let
|
|
|
|
cfg = config.services.radicale;
|
2025-01-04 23:17:35 +00:00
|
|
|
cfgInit = config.init.services.radicale;
|
2025-01-04 10:22:05 +00:00
|
|
|
|
|
|
|
settingsFormat = pkgs.formats.ini {
|
|
|
|
listToValue = lib.concatMapStringsSep ", " (lib.generators.mkValueStringDefault {});
|
|
|
|
};
|
|
|
|
in {
|
|
|
|
options.services.radicale = {
|
|
|
|
enable = lib.mkEnableOption "radicale";
|
|
|
|
package = lib.mkPackageOption pkgs "radicale" {};
|
2025-01-04 23:17:35 +00:00
|
|
|
|
2025-01-04 10:22:05 +00:00
|
|
|
settings = lib.mkOption {
|
|
|
|
type = settingsFormat.type;
|
|
|
|
default = {};
|
2025-01-04 23:17:35 +00:00
|
|
|
|
2025-01-04 10:22:05 +00:00
|
|
|
description = ''
|
|
|
|
Configuration for Radicale. See
|
|
|
|
<https://radicale.org/v3.html#configuration>.
|
|
|
|
'';
|
2025-01-04 23:17:35 +00:00
|
|
|
|
2025-01-04 10:22:05 +00:00
|
|
|
example = lib.literalExpression ''
|
|
|
|
server = {
|
|
|
|
hosts = [ "0.0.0.0:5232" "[::]:5232" ];
|
|
|
|
};
|
|
|
|
auth = {
|
|
|
|
type = "htpasswd";
|
|
|
|
htpasswd_filename = "/etc/radicale/users";
|
|
|
|
htpasswd_encryption = "bcrypt";
|
|
|
|
};
|
|
|
|
storage = {
|
|
|
|
filesystem_folder = "/var/lib/radicale/collections";
|
|
|
|
};
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
2025-01-04 23:17:35 +00:00
|
|
|
|
2025-01-04 10:22:05 +00:00
|
|
|
config = lib.mkIf cfg.enable (let
|
|
|
|
configFile = settingsFormat.generate "radicale.ini" cfg.settings;
|
|
|
|
in {
|
|
|
|
init.services.radicale = {
|
|
|
|
enabled = true;
|
2025-01-04 22:23:41 +00:00
|
|
|
user = lib.mkDefault "radicale";
|
|
|
|
group = lib.mkDefault "radicale";
|
|
|
|
|
2025-01-04 10:22:05 +00:00
|
|
|
script = pkgs.writeShellScript "radicale-run" ''
|
2025-01-04 22:23:41 +00:00
|
|
|
${cfg.package}/bin/radicale \
|
2025-01-04 10:22:05 +00:00
|
|
|
--config ${configFile}
|
|
|
|
'';
|
|
|
|
};
|
2025-01-04 22:23:41 +00:00
|
|
|
|
2025-01-04 10:22:05 +00:00
|
|
|
environment.systemPackages = [cfg.package];
|
2025-01-04 22:23:41 +00:00
|
|
|
|
2025-01-04 23:17:35 +00:00
|
|
|
users.users.${cfgInit.user} = nglib.mkDefaultRec {
|
2025-01-04 10:22:05 +00:00
|
|
|
description = "radicale";
|
2025-01-04 23:17:35 +00:00
|
|
|
group = cfgInit.group;
|
2025-01-04 10:22:05 +00:00
|
|
|
createHome = false;
|
|
|
|
home = "/var/empty";
|
|
|
|
useDefaultShell = true;
|
|
|
|
uid = config.ids.uids.radicale;
|
|
|
|
};
|
2025-01-04 22:23:41 +00:00
|
|
|
|
2025-01-04 23:17:35 +00:00
|
|
|
users.groups.${cfgInit.group} = nglib.mkDefaultRec {gid = config.ids.gids.radicale;};
|
2025-01-04 10:22:05 +00:00
|
|
|
});
|
|
|
|
}
|