Adding options to enable bitlbee and slack gateways in znc config.

This commit is contained in:
Tom Doggett 2017-05-17 15:03:12 -07:00
parent afec912d81
commit e28203fd48
No known key found for this signature in database
GPG Key ID: C4252D5677A319CA

View File

@ -37,7 +37,7 @@ let
IPv6 = true IPv6 = true
SSL = ${boolToString confOpts.useSSL} SSL = ${boolToString confOpts.useSSL}
</Listener> </Listener>
<User ${confOpts.userName}> <User ${confOpts.userName}>
${confOpts.passBlock} ${confOpts.passBlock}
Admin = true Admin = true
@ -50,9 +50,12 @@ let
${ lib.concatStringsSep "\n" (lib.mapAttrsToList (name: net: '' ${ lib.concatStringsSep "\n" (lib.mapAttrsToList (name: net: ''
<Network ${name}> <Network ${name}>
${concatMapStrings (m: "LoadModule = ${m}\n") net.modules} ${concatMapStrings (m: "LoadModule = ${m}\n") net.modules}
Server = ${net.server} ${if net.useSSL then "+" else ""}${toString net.port} Server = ${net.server} ${lib.optionalString net.useSSL "+"}${toString net.port} ${net.password}
${concatMapStrings (c: "<Chan #${c}>\n</Chan>\n") net.channels} ${concatMapStrings (c: "<Chan #${c}>\n</Chan>\n") net.channels}
${lib.optionalString net.hasBitlbeeControlChannel ''
<Chan &bitlbee></Chan>
''}
${net.extraConf}
</Network> </Network>
'') confOpts.networks) } '') confOpts.networks) }
</User> </User>
@ -85,6 +88,23 @@ let
''; '';
}; };
userName = mkOption {
default = "";
example = "johntron";
type = types.string;
description = ''
A nick identity specific to the IRC server.
'';
};
password = mkOption {
type = types.str;
default = "";
description = ''
IRC server password, such as for a Slack gateway.
'';
};
useSSL = mkOption { useSSL = mkOption {
type = types.bool; type = types.bool;
default = true; default = true;
@ -119,6 +139,31 @@ let
IRC channels to join. IRC channels to join.
''; '';
}; };
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 = ''
Extra config for the network.
'';
};
}; };
}; };
@ -273,21 +318,21 @@ in
A list of global znc module packages to add to znc. A list of global znc module packages to add to znc.
''; '';
}; };
mutable = mkOption { mutable = mkOption {
default = false; default = false;
type = types.bool; type = types.bool;
description = '' description = ''
Indicates whether to allow the contents of the `dataDir` directory to be changed Indicates whether to allow the contents of the `dataDir` directory to be changed
by the user at run-time. by the user at run-time.
If true, modifications to the ZNC configuration after its initial creation are not If true, modifications to the ZNC configuration after its initial creation are not
overwritten by a NixOS system rebuild. overwritten by a NixOS system rebuild.
If false, the ZNC configuration is rebuilt by every system rebuild. If false, the ZNC configuration is rebuilt by every system rebuild.
If the user wants to manage the ZNC service using the web admin interface, this value If the user wants to manage the ZNC service using the web admin interface, this value
should be set to true. should be set to true.
''; '';
}; };
extraFlags = mkOption { extraFlags = mkOption {
default = [ ]; default = [ ];
example = [ "--debug" ]; example = [ "--debug" ];
@ -334,7 +379,7 @@ in
if [[ ! -f ${cfg.dataDir}/znc.pem ]]; then if [[ ! -f ${cfg.dataDir}/znc.pem ]]; then
${pkgs.coreutils}/bin/echo "No znc.pem file found in ${cfg.dataDir}. Creating one now." ${pkgs.coreutils}/bin/echo "No znc.pem file found in ${cfg.dataDir}. Creating one now."
${pkgs.znc}/bin/znc --makepem --datadir ${cfg.dataDir} ${pkgs.znc}/bin/znc --makepem --datadir ${cfg.dataDir}
fi fi
# Symlink modules # Symlink modules
@ -352,7 +397,7 @@ in
home = cfg.dataDir; home = cfg.dataDir;
createHome = true; createHome = true;
}; };
users.extraGroups = optional (cfg.user == defaultUser) users.extraGroups = optional (cfg.user == defaultUser)
{ name = defaultUser; { name = defaultUser;
gid = config.ids.gids.znc; gid = config.ids.gids.znc;