Merge pull request #17394 from schneefux/znc-module

ZNC: 1.6.2 -> 1.6.3, push 2015-12-07 -> 2016-07-28, module refactor
This commit is contained in:
Jörg Thalheim 2016-10-22 19:58:24 +02:00 committed by GitHub
commit fba9d231b4
3 changed files with 138 additions and 88 deletions

View File

@ -26,53 +26,35 @@ let
}; };
# Keep znc.conf in nix store, then symlink or copy into `dataDir`, depending on `mutable`. # Keep znc.conf in nix store, then symlink or copy into `dataDir`, depending on `mutable`.
notNull = a: ! isNull a;
mkZncConf = confOpts: '' mkZncConf = confOpts: ''
// Also check http://en.znc.in/wiki/Configuration Version = 1.6.3
AnonIPLimit = 10
ConnectDelay = 5
# Add `LoadModule = x` for each module...
${concatMapStrings (n: "LoadModule = ${n}\n") confOpts.modules} ${concatMapStrings (n: "LoadModule = ${n}\n") confOpts.modules}
MaxBufferSize = 500
ProtectWebSessions = true
SSLCertFile = ${cfg.dataDir}/znc.pem
ServerThrottle = 30
Skin = dark-clouds
StatusPrefix = *
Version = 1.2
<Listener listener0> <Listener l>
AllowIRC = true Port = ${toString confOpts.port}
AllowWeb = true
IPv4 = true IPv4 = true
IPv6 = false IPv6 = true
Port = ${if confOpts.useSSL then "+" else ""}${toString confOpts.port}
SSL = ${if confOpts.useSSL then "true" else "false"} SSL = ${if confOpts.useSSL then "true" else "false"}
</Listener> </Listener>
<User ${confOpts.userName}> <User ${confOpts.userName}>
${confOpts.passBlock}
Admin = true Admin = true
Allow = *
AltNick = ${confOpts.nick}_
AppendTimestamp = false
AutoClearChanBuffer = false
Buffer = 150
ChanModes = +stn
DenyLoadMod = false
DenySetBindHost = false
Ident = ident
JoinTries = 10
MaxJoins = 0
MaxNetworks = 1
MultiClients = true
Nick = ${confOpts.nick} Nick = ${confOpts.nick}
PrependTimestamp = true AltNick = ${confOpts.nick}_
QuitMsg = Quit Ident = ${confOpts.nick}
RealName = ${confOpts.nick} RealName = ${confOpts.nick}
TimestampFormat = [%H:%M:%S]
${concatMapStrings (n: "LoadModule = ${n}\n") confOpts.userModules} ${concatMapStrings (n: "LoadModule = ${n}\n") confOpts.userModules}
${confOpts.passBlock} ${ 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}
${concatMapStrings (c: "<Chan #${c}>\n</Chan>\n") net.channels}
</Network>
'') confOpts.networks) }
</User> </User>
${confOpts.extraZncConf} ${confOpts.extraZncConf}
''; '';
@ -84,6 +66,62 @@ let
else mkZncConf cfg.confOptions; else mkZncConf cfg.confOptions;
}; };
networkOpts = { ... }: {
options = {
server = mkOption {
type = types.str;
example = "chat.freenode.net";
description = ''
IRC server address.
'';
};
port = mkOption {
type = types.int;
default = 6697;
example = 6697;
description = ''
IRC server port.
'';
};
useSSL = mkOption {
type = types.bool;
default = true;
description = ''
Whether to use SSL to connect to the IRC server.
'';
};
modulePackages = mkOption {
type = types.listOf types.package;
default = [];
example = [ "pkgs.zncModules.push" "pkgs.zncModules.fish" ];
description = ''
External ZNC modules to build.
'';
};
modules = mkOption {
type = types.listOf types.str;
default = [ "simple_away" ];
example = literalExample "[ simple_away sasl ]";
description = ''
ZNC modules to load.
'';
};
channels = mkOption {
type = types.listOf types.str;
default = [];
example = [ "nixos" ];
description = ''
IRC channels to join.
'';
};
};
};
in in
{ {
@ -111,6 +149,15 @@ in
''; '';
}; };
group = mkOption {
default = "";
example = "users";
type = types.string;
description = ''
Group to own the ZNCserver process.
'';
};
dataDir = mkOption { dataDir = mkOption {
default = "/var/lib/znc/"; default = "/var/lib/znc/";
example = "/home/john/.znc/"; example = "/home/john/.znc/";
@ -125,27 +172,16 @@ in
example = "See: http://wiki.znc.in/Configuration"; example = "See: http://wiki.znc.in/Configuration";
type = types.lines; type = types.lines;
description = '' description = ''
The contents of the `znc.conf` file to use when creating it. Config file as generated with `znc --makeconf` to use for the whole ZNC configuration.
If specified, `confOptions` will be ignored, and this value, as-is, will be used. If specified, `confOptions` will be ignored, and this value, as-is, will be used.
If left empty, a conf file with default values will be used. If left empty, a conf file with default values will be used.
Recommended to generate with `znc --makeconf` command.
''; '';
}; };
/* TODO: add to the documentation of the current module:
Values to use when creating a `znc.conf` file.
confOptions = {
modules = [ "log" ];
userName = "john";
nick = "johntron";
};
*/
confOptions = { confOptions = {
modules = mkOption { modules = mkOption {
type = types.listOf types.str; type = types.listOf types.str;
default = [ "partyline" "webadmin" "adminlog" "log" ]; default = [ "webadmin" "adminlog" ];
example = [ "partyline" "webadmin" "adminlog" "log" ]; example = [ "partyline" "webadmin" "adminlog" "log" ];
description = '' description = ''
A list of modules to include in the `znc.conf` file. A list of modules to include in the `znc.conf` file.
@ -154,8 +190,8 @@ in
userModules = mkOption { userModules = mkOption {
type = types.listOf types.str; type = types.listOf types.str;
default = [ ]; default = [ "chansaver" "controlpanel" ];
example = [ "fish" "push" ]; example = [ "chansaver" "controlpanel" "fish" "push" ];
description = '' description = ''
A list of user modules to include in the `znc.conf` file. A list of user modules to include in the `znc.conf` file.
''; '';
@ -166,29 +202,42 @@ in
example = "johntron"; example = "johntron";
type = types.string; type = types.string;
description = '' description = ''
The user name to use when generating the `znc.conf` file. The user name used to log in to the ZNC web admin interface.
This is the user name used by the user logging into the ZNC web admin.
''; '';
}; };
networks = mkOption {
default = { };
type = types.loaOf types.optionSet;
description = ''
IRC networks to connect the user to.
'';
options = [ networkOpts ];
example = {
"freenode" = {
server = "chat.freenode.net";
port = 6697;
ssl = true;
modules = [ "simple_away" ];
};
};
};
nick = mkOption { nick = mkOption {
default = "znc-user"; default = "znc-user";
example = "john"; example = "john";
type = types.string; type = types.string;
description = '' description = ''
The IRC nick to use when generating the `znc.conf` file. The IRC nick.
''; '';
}; };
passBlock = mkOption { passBlock = mkOption {
default = defaultPassBlock; example = defaultPassBlock;
example = "Must be the block generated by the `znc --makepass` command.";
type = types.string; type = types.string;
description = '' description = ''
The pass block to use when generating the `znc.conf` file. Generate with znc --makepass.
This is the password used by the user logging into the ZNC web admin. This is the password used to log in to the ZNC web admin interface.
This is the block generated by the `znc --makepass` command.
!!! If not specified, please change this after starting the service. !!!
''; '';
}; };
@ -206,7 +255,7 @@ in
example = true; example = true;
type = types.bool; type = types.bool;
description = '' description = ''
Indicates whether the ZNC server should use SSL when listening on the specified port. Indicates whether the ZNC server should use SSL when listening on the specified port. A self-signed certificate will be generated.
''; '';
}; };
@ -214,7 +263,7 @@ in
default = ""; default = "";
type = types.lines; type = types.lines;
description = '' description = ''
Extra config to `znc.conf` file Extra config to `znc.conf` file.
''; '';
}; };
}; };
@ -265,6 +314,7 @@ in
after = [ "network.service" ]; after = [ "network.service" ];
serviceConfig = { serviceConfig = {
User = cfg.user; User = cfg.user;
Group = cfg.group;
Restart = "always"; Restart = "always";
ExecReload = "${pkgs.coreutils}/bin/kill -HUP $MAINPID"; ExecReload = "${pkgs.coreutils}/bin/kill -HUP $MAINPID";
ExecStop = "${pkgs.coreutils}/bin/kill -INT $MAINPID"; ExecStop = "${pkgs.coreutils}/bin/kill -INT $MAINPID";

View File

@ -7,11 +7,11 @@
with stdenv.lib; with stdenv.lib;
stdenv.mkDerivation rec { stdenv.mkDerivation rec {
name = "znc-1.6.2"; name = "znc-1.6.3";
src = fetchurl { src = fetchurl {
url = "http://znc.in/releases/${name}.tar.gz"; url = "http://znc.in/releases/${name}.tar.gz";
sha256 = "14q5dyr5zg99hm6j6g1gilcn1zf7dskhxfpz3bnkyhy6q0kpgwgf"; sha256 = "09xqi5fs40x6nj9gq99bnw1a7saq96bvqxknxx0ilq7yfvg4c733";
}; };
buildInputs = [ openssl pkgconfig ] buildInputs = [ openssl pkgconfig ]
@ -28,7 +28,7 @@ stdenv.mkDerivation rec {
meta = with stdenv.lib; { meta = with stdenv.lib; {
description = "Advanced IRC bouncer"; description = "Advanced IRC bouncer";
homepage = http://wiki.znc.in/ZNC; homepage = http://wiki.znc.in/ZNC;
maintainers = with maintainers; [ viric ]; maintainers = with maintainers; [ viric schneefux ];
license = licenses.asl20; license = licenses.asl20;
platforms = platforms.unix; platforms = platforms.unix;
}; };

View File

@ -1,4 +1,4 @@
{ stdenv, fetchurl, fetchgit, znc }: { stdenv, fetchurl, fetchFromGitHub, znc }:
let let
zncDerivation = a@{ zncDerivation = a@{
@ -20,8 +20,9 @@ in rec {
version = "git-2015-08-27"; version = "git-2015-08-27";
module_name = "clientbuffer"; module_name = "clientbuffer";
src = fetchgit { src = fetchFromGitHub {
url = meta.repositories.git; owner = "jpnurmi";
repo = "znc-clientbuffer";
rev = "fe0f368e1fcab2b89d5c94209822d9b616cea840"; rev = "fe0f368e1fcab2b89d5c94209822d9b616cea840";
sha256 = "1s8bqqlwy9kmcpmavil558rd2b0wigjlzp2lpqpcqrd1cg25g4a7"; sha256 = "1s8bqqlwy9kmcpmavil558rd2b0wigjlzp2lpqpcqrd1cg25g4a7";
}; };
@ -29,7 +30,6 @@ in rec {
meta = with stdenv.lib; { meta = with stdenv.lib; {
description = "ZNC module for client specific buffers"; description = "ZNC module for client specific buffers";
homepage = https://github.com/jpnurmi/znc-clientbuffer; homepage = https://github.com/jpnurmi/znc-clientbuffer;
repositories.git = https://github.com/jpnurmi/znc-clientbuffer.git;
license = licenses.asl20; license = licenses.asl20;
maintainers = with maintainers; [ hrdinka ]; maintainers = with maintainers; [ hrdinka ];
}; };
@ -40,8 +40,10 @@ in rec {
version = "git-2014-10-10"; version = "git-2014-10-10";
module_name = "fish"; module_name = "fish";
src = fetchgit { src = fetchFromGitHub {
url = meta.repositories.git; # this fork works with ZNC 1.6
owner = "jarrydpage";
repo = "znc-fish";
rev = "9c580e018a1a08374e814fc06f551281cff827de"; rev = "9c580e018a1a08374e814fc06f551281cff827de";
sha256 = "0yvs0jkwwp18qxqvw1dvir91ggczz56ka00k0zlsb81csdi8xfvl"; sha256 = "0yvs0jkwwp18qxqvw1dvir91ggczz56ka00k0zlsb81csdi8xfvl";
}; };
@ -49,8 +51,6 @@ in rec {
meta = { meta = {
description = "ZNC FiSH module"; description = "ZNC FiSH module";
homepage = https://github.com/dctrwatson/znc-fish; homepage = https://github.com/dctrwatson/znc-fish;
# this fork works with ZNC 1.6
repositories.git = https://github.com/jarrydpage/znc-fish.git;
maintainers = [ stdenv.lib.maintainers.offline ]; maintainers = [ stdenv.lib.maintainers.offline ];
}; };
}; };
@ -60,8 +60,9 @@ in rec {
version = "git-2015-08-04"; version = "git-2015-08-04";
module_name = "playback"; module_name = "playback";
src = fetchgit { src = fetchFromGitHub {
url = meta.repositories.git; owner = "jpnurmi";
repo = "znc-playback";
rev = "8691abf75becc1f3d7b5bb5ad68dad17cd21863b"; rev = "8691abf75becc1f3d7b5bb5ad68dad17cd21863b";
sha256 = "0mgfajljy035051b2sx70i8xrb51zw9q2z64kf85zw1lynihzyh4"; sha256 = "0mgfajljy035051b2sx70i8xrb51zw9q2z64kf85zw1lynihzyh4";
}; };
@ -69,7 +70,6 @@ in rec {
meta = with stdenv.lib; { meta = with stdenv.lib; {
description = "An advanced playback module for ZNC"; description = "An advanced playback module for ZNC";
homepage = https://github.com/jpnurmi/znc-playback; homepage = https://github.com/jpnurmi/znc-playback;
repositories.git = https://github.com/jpnurmi/znc-playback.git;
license = licenses.asl20; license = licenses.asl20;
maintainers = with maintainers; [ hrdinka ]; maintainers = with maintainers; [ hrdinka ];
}; };
@ -80,8 +80,9 @@ in rec {
version = "git-2015-02-22"; version = "git-2015-02-22";
module_name = "privmsg"; module_name = "privmsg";
src = fetchgit { src = fetchFromGitHub {
url = meta.repositories.git; owner = "kylef";
repo = "znc-contrib";
rev = "9f1f98db56cbbea96d83e6628f657e0d62cd9517"; rev = "9f1f98db56cbbea96d83e6628f657e0d62cd9517";
sha256 = "0n82z87gdxxragcaixjc80z8bw4bmfwbk0jrf9zs8kk42phlkkc2"; sha256 = "0n82z87gdxxragcaixjc80z8bw4bmfwbk0jrf9zs8kk42phlkkc2";
}; };
@ -89,27 +90,26 @@ in rec {
meta = { meta = {
description = "ZNC privmsg module"; description = "ZNC privmsg module";
homepage = https://github.com/kylef/znc-contrib; homepage = https://github.com/kylef/znc-contrib;
repositories.git = https://github.com/kylef/znc-contrib.git;
}; };
}; };
push = zncDerivation rec { push = zncDerivation rec {
name = "znc-push-${version}"; name = "znc-push-${version}";
version = "git-2015-12-07"; version = "git-2016-10-12";
module_name = "push"; module_name = "push";
src = fetchgit { src = fetchFromGitHub {
url = "https://github.com/jreese/znc-push.git"; owner = "jreese";
rev = "717a2b1741eee75456b0862ef76dbb5af906e936"; repo = "znc-push";
sha256 = "1ih1hf11mqgi0cfh6v70v3b93xrw83xcb80psmijcqxi7kwjn404"; rev = "cf08b9e0f483f03c28d72dd78df932cbef141f10";
sha256 = "0xpwjw8csyrg736g1jc1n8d6804x6kbdkrvldzhk9ldj4iwqz7ay";
}; };
meta = { meta = {
description = "Push notification service module for ZNC"; description = "Push notification service module for ZNC";
homepage = https://github.com/jreese/znc-push; homepage = https://github.com/jreese/znc-push;
repositories.git = https://github.com/jreese/znc-push.git;
license = stdenv.lib.licenses.mit; license = stdenv.lib.licenses.mit;
maintainers = [ stdenv.lib.maintainers.offline ]; maintainers = with stdenv.lib.maintainers; [ offline schneefux ];
}; };
}; };