Merge pull request #25877 from nocoolnametom/update-znc

znc service: refactor config generation
This commit is contained in:
Jörg Thalheim 2017-05-20 09:49:26 +01:00 committed by GitHub
commit 376fe51da2

View File

@ -37,7 +37,7 @@ let
IPv6 = true
SSL = ${boolToString confOpts.useSSL}
</Listener>
<User ${confOpts.userName}>
${confOpts.passBlock}
Admin = true
@ -50,9 +50,12 @@ let
${ lib.concatStringsSep "\n" (lib.mapAttrsToList (name: net: ''
<Network ${name}>
${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}
${lib.optionalString net.hasBitlbeeControlChannel ''
<Chan &bitlbee></Chan>
''}
${net.extraConf}
</Network>
'') confOpts.networks) }
</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 {
type = types.bool;
default = true;
@ -119,6 +139,31 @@ let
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.
'';
};
mutable = mkOption {
default = false;
type = types.bool;
description = ''
Indicates whether to allow the contents of the `dataDir` directory to be changed
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.
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
should be set to true.
'';
};
extraFlags = mkOption {
default = [ ];
example = [ "--debug" ];
@ -334,7 +379,7 @@ in
if [[ ! -f ${cfg.dataDir}/znc.pem ]]; then
${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
# Symlink modules
@ -352,7 +397,7 @@ in
home = cfg.dataDir;
createHome = true;
};
users.extraGroups = optional (cfg.user == defaultUser)
{ name = defaultUser;
gid = config.ids.gids.znc;