2014-04-14 15:26:48 +01:00
|
|
|
{ config, lib, pkgs, ... }:
|
2010-06-28 19:36:37 +01:00
|
|
|
|
2014-04-14 15:26:48 +01:00
|
|
|
with lib;
|
2010-06-28 19:36:37 +01:00
|
|
|
|
|
|
|
let
|
2015-07-31 03:24:11 +01:00
|
|
|
quassel = pkgs.quasselDaemon_qt5;
|
2010-06-28 19:36:37 +01:00
|
|
|
cfg = config.services.quassel;
|
2010-09-26 02:58:44 +01:00
|
|
|
user = if cfg.user != null then cfg.user else "quassel";
|
2010-06-28 19:36:37 +01:00
|
|
|
in
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
###### interface
|
|
|
|
|
|
|
|
options = {
|
2011-09-14 19:20:50 +01:00
|
|
|
|
2010-06-28 19:36:37 +01:00
|
|
|
services.quassel = {
|
|
|
|
|
|
|
|
enable = mkOption {
|
|
|
|
default = false;
|
|
|
|
description = ''
|
|
|
|
Whether to run the Quassel IRC client daemon.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2015-11-09 16:53:37 +00:00
|
|
|
interfaces = mkOption {
|
|
|
|
default = [ "127.0.0.1" ];
|
2010-06-28 19:36:37 +01:00
|
|
|
description = ''
|
2015-11-09 16:53:37 +00: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 19:36:37 +01: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 02:58:44 +01:00
|
|
|
default = ''/home/${user}/.config/quassel-irc.org'';
|
2010-06-28 19:36:37 +01:00
|
|
|
description = ''
|
|
|
|
The directory holding configuration files, the SQlite database and the SSL Cert.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
user = mkOption {
|
2010-09-26 02:58:44 +01:00
|
|
|
default = null;
|
2010-06-28 19:36:37 +01:00
|
|
|
description = ''
|
2010-09-26 02:58:44 +01:00
|
|
|
The existing user the Quassel daemon should run as. If left empty, a default "quassel" user will be created.
|
2010-06-28 19:36:37 +01:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
2011-09-14 19:20:50 +01:00
|
|
|
|
2010-06-28 19:36:37 +01:00
|
|
|
|
|
|
|
###### implementation
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
|
2010-09-26 02:58:44 +01:00
|
|
|
users.extraUsers = mkIf (cfg.user == null) [
|
2010-09-26 03:10:23 +01:00
|
|
|
{ name = "quassel";
|
2010-06-28 19:36:37 +01:00
|
|
|
description = "Quassel IRC client daemon";
|
2013-08-26 14:20:25 +01:00
|
|
|
group = "quassel";
|
|
|
|
uid = config.ids.uids.quassel;
|
2010-09-26 02:58:44 +01:00
|
|
|
}];
|
2011-09-14 19:20:50 +01:00
|
|
|
|
2013-08-26 14:20:25 +01:00
|
|
|
users.extraGroups = mkIf (cfg.user == null) [
|
|
|
|
{ name = "quassel";
|
|
|
|
gid = config.ids.gids.quassel;
|
|
|
|
}];
|
2010-06-28 19:36:37 +01:00
|
|
|
|
2014-11-08 13:59:07 +00:00
|
|
|
systemd.services.quassel =
|
2010-06-28 19:36:37 +01:00
|
|
|
{ description = "Quassel IRC client daemon";
|
|
|
|
|
2014-11-08 13:59:07 +00:00
|
|
|
wantedBy = [ "multi-user.target" ];
|
2015-08-17 17:35:08 +01:00
|
|
|
after = [ "network.target" ] ++ optional config.services.postgresql.enable "postgresql.service"
|
|
|
|
++ optional config.services.mysql.enable "mysql.service";
|
2010-06-28 19:36:37 +01:00
|
|
|
|
|
|
|
preStart = ''
|
2014-11-08 13:59:07 +00:00
|
|
|
mkdir -p ${cfg.dataDir}
|
|
|
|
chown ${user} ${cfg.dataDir}
|
2010-06-28 19:36:37 +01:00
|
|
|
'';
|
|
|
|
|
2014-11-08 13:59:07 +00:00
|
|
|
serviceConfig =
|
|
|
|
{
|
2015-11-09 16:53:37 +00:00
|
|
|
ExecStart = "${quassel}/bin/quasselcore --listen=${concatStringsSep '','' cfg.interfaces} --port=${toString cfg.portNumber} --configdir=${cfg.dataDir}";
|
2014-11-08 13:59:07 +00:00
|
|
|
User = user;
|
|
|
|
PermissionsStartOnly = true;
|
|
|
|
};
|
2010-06-28 19:36:37 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
};
|
2011-09-14 19:20:50 +01:00
|
|
|
|
2010-06-28 19:36:37 +01:00
|
|
|
}
|