nixpkgs/nixos/modules/services/networking/radicale.nix

93 lines
2.3 KiB
Nix
Raw Normal View History

{ 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;
2020-06-20 13:30:33 +01: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 {
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 = ''
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 13:30:33 +01:00
<literal>system.stateVersion &lt; 17.09</literal>, version 2.x if
<literal>17.09 system.stateVersion &lt; 20.09</literal>, and
version 3.x otherwise.
2014-05-27 21:27:31 +01:00
'';
};
services.radicale.config = mkOption {
type = types.str;
2014-05-27 21:27:31 +01:00
default = "";
description = ''
Radicale configuration, this will set the service
configuration file.
2014-05-27 21:27:31 +01:00
'';
};
services.radicale.extraArgs = mkOption {
type = types.listOf types.str;
default = [];
description = "Extra arguments passed to the Radicale daemon.";
};
2014-05-27 21:27:31 +01:00
};
config = mkIf cfg.enable {
environment.systemPackages = [ cfg.package ];
2014-05-27 21:27:31 +01:00
users.users.radicale =
{ uid = config.ids.uids.radicale;
description = "radicale user";
home = "/var/lib/radicale";
createHome = true;
};
users.groups.radicale =
{ gid = config.ids.gids.radicale; };
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";
after = [ "network.target" ];
2016-01-06 06:50:18 +00:00
wantedBy = [ "multi-user.target" ];
serviceConfig = {
ExecStart = concatStringsSep " " ([
"${cfg.package}/bin/radicale" "-C" confFile
] ++ (
map escapeShellArg cfg.extraArgs
));
User = "radicale";
Group = "radicale";
};
2014-05-27 21:27:31 +01:00
};
};
2017-03-20 16:13:27 +00:00
meta.maintainers = with lib.maintainers; [ aneeshusa infinisil ];
2014-05-27 21:27:31 +01:00
}