2010-06-28 19:36:37 +01:00
|
|
|
{ config, pkgs, ... }:
|
|
|
|
|
|
|
|
with pkgs.lib;
|
|
|
|
|
|
|
|
let
|
2010-09-18 12:30:09 +01:00
|
|
|
quassel = pkgs.quasselDaemon;
|
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 = {
|
|
|
|
|
|
|
|
services.quassel = {
|
|
|
|
|
|
|
|
enable = mkOption {
|
|
|
|
default = false;
|
|
|
|
description = ''
|
|
|
|
Whether to run the Quassel IRC client daemon.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
interface = mkOption {
|
|
|
|
default = "127.0.0.1";
|
|
|
|
description = ''
|
|
|
|
The interface 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
|
|
|
|
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
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
###### 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";
|
2010-09-26 02:58:44 +01:00
|
|
|
}];
|
2010-06-28 19:36:37 +01:00
|
|
|
|
|
|
|
|
|
|
|
jobs.quassel =
|
|
|
|
{ description = "Quassel IRC client daemon";
|
|
|
|
|
|
|
|
startOn = "ip-up";
|
|
|
|
|
|
|
|
preStart = ''
|
|
|
|
mkdir -p ${cfg.dataDir}
|
2010-09-26 02:58:44 +01:00
|
|
|
chown ${user} ${cfg.dataDir}
|
2010-06-28 19:36:37 +01:00
|
|
|
'';
|
|
|
|
|
|
|
|
exec = ''
|
2010-09-26 02:58:44 +01:00
|
|
|
${pkgs.su}/bin/su -s ${pkgs.stdenv.shell} ${user} \
|
2010-06-28 19:36:37 +01:00
|
|
|
-c '${quassel}/bin/quasselcore --listen=${cfg.interface}\
|
2010-09-18 13:50:55 +01:00
|
|
|
--port=${toString cfg.portNumber} --configdir=${cfg.dataDir}'
|
2010-06-28 19:36:37 +01:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|