2014-04-14 16:26:48 +02:00
|
|
|
{ config, lib, pkgs, ... }:
|
2010-06-28 20:36:37 +02:00
|
|
|
|
2014-04-14 16:26:48 +02:00
|
|
|
with lib;
|
2010-06-28 20:36:37 +02:00
|
|
|
|
|
|
|
let
|
|
|
|
cfg = config.services.quassel;
|
2016-11-04 16:33:47 +01:00
|
|
|
quassel = cfg.package;
|
2010-09-26 03:58:44 +02:00
|
|
|
user = if cfg.user != null then cfg.user else "quassel";
|
2010-06-28 20:36:37 +02:00
|
|
|
in
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
###### interface
|
|
|
|
|
|
|
|
options = {
|
2011-09-14 20:20:50 +02:00
|
|
|
|
2010-06-28 20:36:37 +02:00
|
|
|
services.quassel = {
|
|
|
|
|
|
|
|
enable = mkOption {
|
|
|
|
default = false;
|
|
|
|
description = ''
|
|
|
|
Whether to run the Quassel IRC client daemon.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2019-02-14 14:31:41 +01:00
|
|
|
certificateFile = mkOption {
|
|
|
|
type = types.nullOr types.str;
|
|
|
|
default = null;
|
|
|
|
description = ''
|
|
|
|
Path to the certificate used for SSL connections with clients.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
requireSSL = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
|
|
|
description = ''
|
|
|
|
Require SSL for connections from clients.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2016-11-04 16:33:47 +01:00
|
|
|
package = mkOption {
|
|
|
|
type = types.package;
|
2017-02-16 00:44:11 +01:00
|
|
|
default = pkgs.quasselDaemon;
|
|
|
|
defaultText = "pkgs.quasselDaemon";
|
2016-11-04 16:33:47 +01:00
|
|
|
description = ''
|
|
|
|
The package of the quassel daemon.
|
|
|
|
'';
|
2017-02-16 00:44:11 +01:00
|
|
|
example = literalExample "pkgs.quasselDaemon";
|
2016-11-04 16:33:47 +01:00
|
|
|
};
|
|
|
|
|
2015-11-09 17:53:37 +01:00
|
|
|
interfaces = mkOption {
|
|
|
|
default = [ "127.0.0.1" ];
|
2010-06-28 20:36:37 +02:00
|
|
|
description = ''
|
2015-11-09 17:53:37 +01:00
|
|
|
The interfaces the Quassel daemon will be listening to. If `[ 127.0.0.1 ]',
|
|
|
|
only clients on the local host can connect to it; if `[ 0.0.0.0 ]', clients
|
2010-06-28 20:36:37 +02:00
|
|
|
can access it from any network interface.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
portNumber = mkOption {
|
|
|
|
default = 4242;
|
|
|
|
description = ''
|
|
|
|
The port number the Quassel daemon will be listening to.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
dataDir = mkOption {
|
2010-09-26 03:58:44 +02:00
|
|
|
default = ''/home/${user}/.config/quassel-irc.org'';
|
2010-06-28 20:36:37 +02:00
|
|
|
description = ''
|
|
|
|
The directory holding configuration files, the SQlite database and the SSL Cert.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
user = mkOption {
|
2010-09-26 03:58:44 +02:00
|
|
|
default = null;
|
2010-06-28 20:36:37 +02:00
|
|
|
description = ''
|
2010-09-26 03:58:44 +02:00
|
|
|
The existing user the Quassel daemon should run as. If left empty, a default "quassel" user will be created.
|
2010-06-28 20:36:37 +02:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
2011-09-14 20:20:50 +02:00
|
|
|
|
2010-06-28 20:36:37 +02:00
|
|
|
|
|
|
|
###### implementation
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
2019-02-14 14:31:41 +01:00
|
|
|
assertions = [
|
|
|
|
{ assertion = cfg.requireSSL -> cfg.certificateFile != null;
|
|
|
|
message = "Quassel needs a certificate file in order to require SSL";
|
|
|
|
}];
|
2010-06-28 20:36:37 +02:00
|
|
|
|
2018-06-30 01:58:35 +02:00
|
|
|
users.users = mkIf (cfg.user == null) [
|
2010-09-26 04:10:23 +02:00
|
|
|
{ name = "quassel";
|
2010-06-28 20:36:37 +02:00
|
|
|
description = "Quassel IRC client daemon";
|
2013-08-26 15:20:25 +02:00
|
|
|
group = "quassel";
|
|
|
|
uid = config.ids.uids.quassel;
|
2010-09-26 03:58:44 +02:00
|
|
|
}];
|
2011-09-14 20:20:50 +02:00
|
|
|
|
2018-06-30 01:58:35 +02:00
|
|
|
users.groups = mkIf (cfg.user == null) [
|
2013-08-26 15:20:25 +02:00
|
|
|
{ name = "quassel";
|
|
|
|
gid = config.ids.gids.quassel;
|
|
|
|
}];
|
2010-06-28 20:36:37 +02:00
|
|
|
|
2019-02-24 14:56:36 +01:00
|
|
|
systemd.tmpfiles.rules = [
|
|
|
|
"d '${cfg.dataDir}' - ${user} - - -"
|
|
|
|
];
|
|
|
|
|
2014-11-08 14:59:07 +01:00
|
|
|
systemd.services.quassel =
|
2010-06-28 20:36:37 +02:00
|
|
|
{ description = "Quassel IRC client daemon";
|
|
|
|
|
2014-11-08 14:59:07 +01:00
|
|
|
wantedBy = [ "multi-user.target" ];
|
2015-08-17 18:35:08 +02:00
|
|
|
after = [ "network.target" ] ++ optional config.services.postgresql.enable "postgresql.service"
|
|
|
|
++ optional config.services.mysql.enable "mysql.service";
|
2010-06-28 20:36:37 +02:00
|
|
|
|
2014-11-08 14:59:07 +01:00
|
|
|
serviceConfig =
|
|
|
|
{
|
2019-02-14 14:31:41 +01:00
|
|
|
ExecStart = concatStringsSep " " ([
|
|
|
|
"${quassel}/bin/quasselcore"
|
|
|
|
"--listen=${concatStringsSep "," cfg.interfaces}"
|
|
|
|
"--port=${toString cfg.portNumber}"
|
|
|
|
"--configdir=${cfg.dataDir}"
|
|
|
|
] ++ optional cfg.requireSSL "--require-ssl"
|
|
|
|
++ optional (cfg.certificateFile != null) "--ssl-cert=${cfg.certificateFile}");
|
2014-11-08 14:59:07 +01:00
|
|
|
User = user;
|
|
|
|
};
|
2010-06-28 20:36:37 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
};
|
2011-09-14 20:20:50 +02:00
|
|
|
|
2010-06-28 20:36:37 +02:00
|
|
|
}
|