2018-08-21 20:05:20 +01:00
|
|
|
{ lib, config, ... }:
|
2014-05-08 21:20:08 +01:00
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
|
2018-08-21 20:05:20 +01:00
|
|
|
cfg = config.services.znc;
|
2014-05-08 21:20:08 +01:00
|
|
|
|
2018-08-21 20:05:20 +01:00
|
|
|
networkOpts = {
|
2016-08-01 16:24:13 +01:00
|
|
|
options = {
|
2018-08-21 21:16:48 +01:00
|
|
|
|
2016-08-01 16:24:13 +01:00
|
|
|
server = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
example = "chat.freenode.net";
|
|
|
|
description = ''
|
|
|
|
IRC server address.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
port = mkOption {
|
2018-08-21 21:16:48 +01:00
|
|
|
type = types.ints.u16;
|
2016-08-01 16:24:13 +01:00
|
|
|
default = 6697;
|
|
|
|
description = ''
|
|
|
|
IRC server port.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2017-05-17 23:03:12 +01:00
|
|
|
password = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "";
|
|
|
|
description = ''
|
|
|
|
IRC server password, such as for a Slack gateway.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2016-08-01 16:24:13 +01:00
|
|
|
useSSL = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = true;
|
|
|
|
description = ''
|
|
|
|
Whether to use SSL to connect to the IRC server.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
modules = mkOption {
|
|
|
|
type = types.listOf types.str;
|
|
|
|
default = [ "simple_away" ];
|
|
|
|
example = literalExample "[ simple_away sasl ]";
|
|
|
|
description = ''
|
2018-08-21 21:16:48 +01:00
|
|
|
ZNC network modules to load.
|
2016-08-01 16:24:13 +01:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
channels = mkOption {
|
|
|
|
type = types.listOf types.str;
|
|
|
|
default = [];
|
|
|
|
example = [ "nixos" ];
|
|
|
|
description = ''
|
|
|
|
IRC channels to join.
|
|
|
|
'';
|
|
|
|
};
|
2017-05-17 23:03:12 +01:00
|
|
|
|
|
|
|
hasBitlbeeControlChannel = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
|
|
|
description = ''
|
|
|
|
Whether to add the special Bitlbee operations channel.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
extraConf = mkOption {
|
|
|
|
default = "";
|
|
|
|
type = types.lines;
|
|
|
|
example = ''
|
|
|
|
Encoding = ^UTF-8
|
|
|
|
FloodBurst = 4
|
|
|
|
FloodRate = 1.00
|
|
|
|
IRCConnectEnabled = true
|
|
|
|
Ident = johntron
|
|
|
|
JoinDelay = 0
|
|
|
|
Nick = johntron
|
|
|
|
'';
|
|
|
|
description = ''
|
2018-08-21 21:16:48 +01:00
|
|
|
Extra config for the network. Consider using
|
|
|
|
<option>services.znc.config</option> instead.
|
2017-05-17 23:03:12 +01:00
|
|
|
'';
|
|
|
|
};
|
2016-08-01 16:24:13 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2014-05-08 21:20:08 +01:00
|
|
|
in
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
options = {
|
|
|
|
services.znc = {
|
2017-09-27 20:16:22 +01:00
|
|
|
|
2018-08-21 21:16:48 +01:00
|
|
|
useLegacyConfig = mkOption {
|
|
|
|
default = true;
|
|
|
|
type = types.bool;
|
2014-05-08 21:20:08 +01:00
|
|
|
description = ''
|
2018-08-21 21:16:48 +01:00
|
|
|
Whether to propagate the legacy options under
|
|
|
|
<option>services.znc.confOptions.*</option> to the znc config. If this
|
|
|
|
is turned on, the znc config will contain a user with the default name
|
|
|
|
"znc", global modules "webadmin" and "adminlog" will be enabled by
|
|
|
|
default, and more, all controlled through the
|
|
|
|
<option>services.znc.confOptions.*</option> options.
|
|
|
|
You can use <command>nix-instantiate --eval --strict '<nixpkgs/nixos>' -A config.services.znc.config</command>
|
|
|
|
to view the current value of the config.
|
|
|
|
</para>
|
|
|
|
<para>
|
|
|
|
In any case, if you need more flexibility,
|
|
|
|
<option>services.znc.config</option> can be used to override/add to
|
|
|
|
all of the legacy options.
|
2014-05-08 21:20:08 +01:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2014-08-29 17:43:03 +01:00
|
|
|
confOptions = {
|
|
|
|
modules = mkOption {
|
2015-06-15 17:18:46 +01:00
|
|
|
type = types.listOf types.str;
|
2016-08-01 16:24:13 +01:00
|
|
|
default = [ "webadmin" "adminlog" ];
|
2014-08-29 17:43:03 +01:00
|
|
|
example = [ "partyline" "webadmin" "adminlog" "log" ];
|
|
|
|
description = ''
|
|
|
|
A list of modules to include in the `znc.conf` file.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
userModules = mkOption {
|
2015-06-15 17:18:46 +01:00
|
|
|
type = types.listOf types.str;
|
2016-08-01 16:24:13 +01:00
|
|
|
default = [ "chansaver" "controlpanel" ];
|
|
|
|
example = [ "chansaver" "controlpanel" "fish" "push" ];
|
2014-08-29 17:43:03 +01:00
|
|
|
description = ''
|
|
|
|
A list of user modules to include in the `znc.conf` file.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
userName = mkOption {
|
2018-08-21 21:16:48 +01:00
|
|
|
default = "znc";
|
2014-08-29 17:43:03 +01:00
|
|
|
example = "johntron";
|
2018-08-21 21:16:48 +01:00
|
|
|
type = types.str;
|
2014-08-29 17:43:03 +01:00
|
|
|
description = ''
|
2016-08-01 16:24:13 +01:00
|
|
|
The user name used to log in to the ZNC web admin interface.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
networks = mkOption {
|
|
|
|
default = { };
|
2016-11-16 07:33:06 +00:00
|
|
|
type = with types; attrsOf (submodule networkOpts);
|
2016-08-01 16:24:13 +01:00
|
|
|
description = ''
|
|
|
|
IRC networks to connect the user to.
|
2014-08-29 17:43:03 +01:00
|
|
|
'';
|
2018-08-21 21:16:48 +01:00
|
|
|
example = literalExample ''
|
|
|
|
{
|
|
|
|
"freenode" = {
|
|
|
|
server = "chat.freenode.net";
|
|
|
|
port = 6697;
|
|
|
|
useSSL = true;
|
|
|
|
modules = [ "simple_away" ];
|
|
|
|
};
|
2016-08-01 16:24:13 +01:00
|
|
|
};
|
2018-08-21 21:16:48 +01:00
|
|
|
'';
|
2014-08-29 17:43:03 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
nick = mkOption {
|
|
|
|
default = "znc-user";
|
|
|
|
example = "john";
|
2018-08-21 21:16:48 +01:00
|
|
|
type = types.str;
|
2014-08-29 17:43:03 +01:00
|
|
|
description = ''
|
2016-08-01 16:24:13 +01:00
|
|
|
The IRC nick.
|
2014-08-29 17:43:03 +01:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
passBlock = mkOption {
|
2018-08-21 21:16:48 +01:00
|
|
|
example = literalExample ''
|
|
|
|
<Pass password>
|
|
|
|
Method = sha256
|
|
|
|
Hash = e2ce303c7ea75c571d80d8540a8699b46535be6a085be3414947d638e48d9e93
|
|
|
|
Salt = l5Xryew4g*!oa(ECfX2o
|
|
|
|
</Pass>
|
|
|
|
'';
|
|
|
|
type = types.str;
|
2014-08-29 17:43:03 +01:00
|
|
|
description = ''
|
2017-05-23 21:22:28 +01:00
|
|
|
Generate with `nix-shell -p znc --command "znc --makepass"`.
|
2016-08-01 16:24:13 +01:00
|
|
|
This is the password used to log in to the ZNC web admin interface.
|
2018-08-21 21:16:48 +01:00
|
|
|
You can also set this through
|
|
|
|
<option>services.znc.config.User.<username>.Pass.Method</option>
|
|
|
|
and co.
|
2014-08-29 17:43:03 +01:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
port = mkOption {
|
|
|
|
default = 5000;
|
|
|
|
type = types.int;
|
|
|
|
description = ''
|
|
|
|
Specifies the port on which to listen.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
useSSL = mkOption {
|
|
|
|
default = true;
|
|
|
|
type = types.bool;
|
|
|
|
description = ''
|
2018-08-21 21:16:48 +01:00
|
|
|
Indicates whether the ZNC server should use SSL when listening on
|
|
|
|
the specified port. A self-signed certificate will be generated.
|
2014-08-29 17:43:03 +01:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2018-04-02 11:04:53 +01:00
|
|
|
uriPrefix = mkOption {
|
|
|
|
type = types.nullOr types.str;
|
|
|
|
default = null;
|
|
|
|
example = "/znc/";
|
|
|
|
description = ''
|
|
|
|
An optional URI prefix for the ZNC web interface. Can be
|
|
|
|
used to make ZNC available behind a reverse proxy.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2014-08-29 17:43:03 +01:00
|
|
|
extraZncConf = mkOption {
|
|
|
|
default = "";
|
|
|
|
type = types.lines;
|
|
|
|
description = ''
|
2016-08-01 16:24:13 +01:00
|
|
|
Extra config to `znc.conf` file.
|
2014-08-29 17:43:03 +01:00
|
|
|
'';
|
2014-05-08 21:20:08 +01:00
|
|
|
};
|
|
|
|
};
|
2014-07-03 14:34:52 +01:00
|
|
|
|
2017-09-10 11:41:39 +01:00
|
|
|
};
|
2014-05-08 21:20:08 +01:00
|
|
|
};
|
2018-08-21 21:16:48 +01:00
|
|
|
|
|
|
|
config = mkIf cfg.useLegacyConfig {
|
|
|
|
|
|
|
|
services.znc.config = let
|
|
|
|
c = cfg.confOptions;
|
|
|
|
# defaults here should override defaults set in the non-legacy part
|
|
|
|
mkDefault = mkOverride 900;
|
|
|
|
in {
|
|
|
|
LoadModule = mkDefault c.modules;
|
|
|
|
Listener.l = {
|
|
|
|
Port = mkDefault c.port;
|
|
|
|
IPv4 = mkDefault true;
|
|
|
|
IPv6 = mkDefault true;
|
|
|
|
SSL = mkDefault c.useSSL;
|
2018-10-20 19:56:30 +01:00
|
|
|
URIPrefix = c.uriPrefix;
|
2018-08-21 21:16:48 +01:00
|
|
|
};
|
|
|
|
User.${c.userName} = {
|
|
|
|
Admin = mkDefault true;
|
|
|
|
Nick = mkDefault c.nick;
|
|
|
|
AltNick = mkDefault "${c.nick}_";
|
|
|
|
Ident = mkDefault c.nick;
|
|
|
|
RealName = mkDefault c.nick;
|
|
|
|
LoadModule = mkDefault c.userModules;
|
|
|
|
Network = mapAttrs (name: net: {
|
|
|
|
LoadModule = mkDefault net.modules;
|
|
|
|
Server = mkDefault "${net.server} ${optionalString net.useSSL "+"}${toString net.port} ${net.password}";
|
|
|
|
Chan = optionalAttrs net.hasBitlbeeControlChannel { "&bitlbee" = mkDefault {}; } //
|
|
|
|
listToAttrs (map (n: nameValuePair "#${n}" (mkDefault {})) net.channels);
|
|
|
|
extraConfig = if net.extraConf == "" then mkDefault null else net.extraConf;
|
|
|
|
}) c.networks;
|
2018-10-20 19:36:18 +01:00
|
|
|
extraConfig = [ c.passBlock ];
|
2018-08-21 21:16:48 +01:00
|
|
|
};
|
2018-10-20 19:36:18 +01:00
|
|
|
extraConfig = optional (c.extraZncConf != "") c.extraZncConf;
|
2018-08-21 21:16:48 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
imports = [
|
|
|
|
(mkRemovedOptionModule ["services" "znc" "zncConf"] ''
|
|
|
|
Instead of `services.znc.zncConf = "... foo ...";`, use
|
|
|
|
`services.znc.configFile = pkgs.writeText "znc.conf" "... foo ...";`.
|
|
|
|
'')
|
|
|
|
];
|
2014-05-08 21:20:08 +01:00
|
|
|
}
|