2015-05-07 16:49:01 +01:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
cfg = config.services.taskserver;
|
|
|
|
in {
|
|
|
|
|
|
|
|
options = {
|
|
|
|
services.taskserver = {
|
|
|
|
|
2015-09-27 18:30:02 +01:00
|
|
|
enable = mkEnableOption "the Taskwarrior server";
|
2015-05-07 16:49:01 +01:00
|
|
|
|
|
|
|
user = mkOption {
|
2015-09-27 18:30:02 +01:00
|
|
|
type = types.str;
|
2015-05-07 16:49:01 +01:00
|
|
|
default = "taskd";
|
2015-09-27 18:30:02 +01:00
|
|
|
description = "User for Taskserver.";
|
2015-05-07 16:49:01 +01:00
|
|
|
};
|
|
|
|
|
2015-09-27 14:35:42 +01:00
|
|
|
group = mkOption {
|
2015-09-27 18:30:02 +01:00
|
|
|
type = types.str;
|
2015-09-27 14:35:42 +01:00
|
|
|
default = "taskd";
|
2015-09-27 18:30:02 +01:00
|
|
|
description = "Group for Taskserver.";
|
2015-09-27 14:35:42 +01:00
|
|
|
};
|
|
|
|
|
2015-05-07 16:49:01 +01:00
|
|
|
dataDir = mkOption {
|
|
|
|
type = types.path;
|
2015-09-27 18:30:02 +01:00
|
|
|
default = "/var/lib/taskserver";
|
|
|
|
description = "Data directory for Taskserver.";
|
2015-05-07 16:49:01 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
caCert = mkOption {
|
2015-09-27 18:30:02 +01:00
|
|
|
type = types.nullOr types.path;
|
|
|
|
default = null;
|
|
|
|
description = "Fully qualified path to the CA certificate.";
|
2015-05-07 16:49:01 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
ciphers = mkOption {
|
2015-09-27 18:30:02 +01:00
|
|
|
type = types.nullOr types.string;
|
|
|
|
default = null;
|
|
|
|
example = "NORMAL";
|
2015-05-07 16:49:01 +01:00
|
|
|
description = ''
|
2015-09-27 18:30:02 +01:00
|
|
|
List of GnuTLS ciphers to use. See the GnuTLS documentation for full
|
|
|
|
details.
|
2015-05-07 16:49:01 +01:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
confirmation = mkOption {
|
2015-09-27 18:30:02 +01:00
|
|
|
type = types.bool;
|
2015-05-07 16:49:01 +01:00
|
|
|
default = true;
|
|
|
|
description = ''
|
|
|
|
Determines whether certain commands are confirmed.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
debug = mkOption {
|
2015-09-27 18:30:02 +01:00
|
|
|
type = types.bool;
|
2015-05-07 16:49:01 +01:00
|
|
|
default = false;
|
|
|
|
description = ''
|
|
|
|
Logs debugging information.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
extensions = mkOption {
|
2015-09-27 18:30:02 +01:00
|
|
|
type = types.nullOr types.path;
|
|
|
|
default = null;
|
2015-05-07 16:49:01 +01:00
|
|
|
description = ''
|
2015-09-27 18:30:02 +01:00
|
|
|
Fully qualified path of the Taskserver extension scripts.
|
|
|
|
Currently there are none.
|
2015-05-07 16:49:01 +01:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
ipLog = mkOption {
|
2015-09-27 18:30:02 +01:00
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
2015-05-07 16:49:01 +01:00
|
|
|
description = ''
|
|
|
|
Logs the IP addresses of incoming requests.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
queueSize = mkOption {
|
2015-09-27 18:30:02 +01:00
|
|
|
type = types.int;
|
2015-05-07 16:49:01 +01:00
|
|
|
default = 10;
|
|
|
|
description = ''
|
2015-09-27 18:30:02 +01:00
|
|
|
Size of the connection backlog, see <citerefentry>
|
|
|
|
<refentrytitle>listen</refentrytitle>
|
|
|
|
<manvolnum>2</manvolnum>
|
|
|
|
</citerefentry>.
|
2015-05-07 16:49:01 +01:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
requestLimit = mkOption {
|
2015-09-27 18:30:02 +01:00
|
|
|
type = types.int;
|
2015-05-07 16:49:01 +01:00
|
|
|
default = 1048576;
|
|
|
|
description = ''
|
|
|
|
Size limit of incoming requests, in bytes.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
client = {
|
|
|
|
|
|
|
|
allow = mkOption {
|
2015-09-27 18:30:02 +01:00
|
|
|
type = types.listOf types.str;
|
|
|
|
default = [];
|
|
|
|
example = [ "[Tt]ask [2-9]+" ];
|
2015-05-07 16:49:01 +01:00
|
|
|
description = ''
|
2015-09-27 18:30:02 +01:00
|
|
|
A list of regular expressions that are matched against the reported
|
|
|
|
client id (such as <literal>task 2.3.0</literal>).
|
|
|
|
|
|
|
|
The values <literal>all</literal> or <literal>none</literal> have
|
|
|
|
special meaning. Overidden by any entry in the option
|
|
|
|
<option>services.taskserver.client.deny</option>.
|
2015-05-07 16:49:01 +01:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
cert = mkOption {
|
2015-09-27 18:30:02 +01:00
|
|
|
type = types.nullOr types.path;
|
|
|
|
default = null;
|
2015-05-07 16:49:01 +01:00
|
|
|
description = ''
|
2015-09-27 18:30:02 +01:00
|
|
|
Fully qualified path of the client cert. This is used by the
|
|
|
|
<command>client</command> command.
|
2015-05-07 16:49:01 +01:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
deny = mkOption {
|
2015-09-27 18:30:02 +01:00
|
|
|
type = types.listOf types.str;
|
|
|
|
default = [];
|
|
|
|
example = [ "[Tt]ask [2-9]+" ];
|
2015-05-07 16:49:01 +01:00
|
|
|
description = ''
|
2015-09-27 18:30:02 +01:00
|
|
|
A list of regular expressions that are matched against the reported
|
|
|
|
client id (such as <literal>task 2.3.0</literal>).
|
|
|
|
|
|
|
|
The values <literal>all</literal> or <literal>none</literal> have
|
|
|
|
special meaning. Any entry here overrides these in
|
|
|
|
<option>services.taskserver.client.allow</option>.
|
2015-05-07 16:49:01 +01:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
server = {
|
|
|
|
host = mkOption {
|
2015-09-27 18:30:02 +01:00
|
|
|
type = types.string;
|
2015-05-07 16:49:01 +01:00
|
|
|
default = "localhost";
|
|
|
|
description = ''
|
|
|
|
The address (IPv4, IPv6 or DNS) of the Taskserver.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
port = mkOption {
|
2015-09-27 18:30:02 +01:00
|
|
|
type = types.int;
|
2015-05-07 16:49:01 +01:00
|
|
|
default = 53589;
|
|
|
|
description = ''
|
2015-09-27 18:30:02 +01:00
|
|
|
Port number of the Taskserver.
|
2015-05-07 16:49:01 +01:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
cert = mkOption {
|
2015-09-27 18:30:02 +01:00
|
|
|
type = types.nullOr types.path;
|
|
|
|
default = null;
|
2015-05-07 16:49:01 +01:00
|
|
|
description = "Fully qualified path to the server certificate";
|
|
|
|
};
|
|
|
|
|
|
|
|
crl = mkOption {
|
2015-09-27 18:30:02 +01:00
|
|
|
type = types.nullOr types.path;
|
|
|
|
default = null;
|
2015-05-07 16:49:01 +01:00
|
|
|
description = ''
|
2015-09-27 18:30:02 +01:00
|
|
|
Fully qualified path to the server certificate revocation list.
|
2015-05-07 16:49:01 +01:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
key = mkOption {
|
2015-09-27 18:30:02 +01:00
|
|
|
type = types.nullOr types.path;
|
|
|
|
default = null;
|
2015-05-07 16:49:01 +01:00
|
|
|
description = ''
|
|
|
|
Fully qualified path to the server key.
|
|
|
|
|
2015-09-27 18:30:02 +01:00
|
|
|
Note that reloading the <literal>taskserver.service</literal> causes
|
|
|
|
a configuration file reload before the next request is handled.
|
2015-05-07 16:49:01 +01:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
|
|
|
|
environment.systemPackages = [ pkgs.taskserver ];
|
|
|
|
|
2015-09-27 14:35:42 +01:00
|
|
|
users.users = optional (cfg.user == "taskd") {
|
|
|
|
name = "taskd";
|
|
|
|
uid = config.ids.uids.taskd;
|
|
|
|
description = "Taskserver user";
|
|
|
|
group = cfg.group;
|
|
|
|
};
|
|
|
|
|
|
|
|
users.groups = optional (cfg.group == "taskd") {
|
|
|
|
name = "taskd";
|
|
|
|
gid = config.ids.gids.taskd;
|
|
|
|
};
|
|
|
|
|
2015-05-07 16:49:01 +01:00
|
|
|
systemd.services.taskserver = {
|
|
|
|
description = "taskserver Service.";
|
|
|
|
path = [ pkgs.taskserver ];
|
|
|
|
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
after = [ "network.target" ];
|
|
|
|
|
|
|
|
preStart = ''
|
2015-09-27 11:43:53 +01:00
|
|
|
mkdir -p "${cfg.dataDir}"
|
|
|
|
|
|
|
|
if [[ ! -e "${cfg.dataDir}/.is_initialized" ]]
|
|
|
|
then
|
|
|
|
${pkgs.taskserver}/bin/taskd init
|
|
|
|
${pkgs.taskserver}/pki/generate
|
|
|
|
for file in {{client,server}.{cert,key},server.crl,ca.cert}
|
|
|
|
do
|
|
|
|
cp $file.pem "${cfg.dataDir}/"
|
|
|
|
${pkgs.taskserver}/bin/taskd config --force \
|
|
|
|
$file "${cfg.dataDir}/$file.pem"
|
|
|
|
done
|
|
|
|
|
|
|
|
${pkgs.taskserver}/bin/taskd config --force server ${cfg.server.host}:${toString cfg.server.port}
|
|
|
|
|
|
|
|
touch "${cfg.dataDir}/.is_initialized"
|
|
|
|
else
|
|
|
|
# already initialized
|
|
|
|
echo "Taskd was initialized. Not initializing again"
|
|
|
|
fi
|
2015-05-07 16:49:01 +01:00
|
|
|
'';
|
|
|
|
|
|
|
|
environment = {
|
|
|
|
TASKDDATA = "${cfg.dataDir}";
|
|
|
|
};
|
|
|
|
|
|
|
|
serviceConfig = {
|
|
|
|
ExecStart = "${pkgs.taskserver}/bin/taskdctl start";
|
|
|
|
ExecStop = "${pkgs.taskserver}/bin/taskdctl stop";
|
|
|
|
User = cfg.user;
|
2015-09-27 14:35:42 +01:00
|
|
|
Group = cfg.group;
|
2015-05-07 16:49:01 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|