summaryrefslogtreecommitdiffstats
path: root/krebs/3modules/newsbot-js.nix
diff options
context:
space:
mode:
authormakefu <github@syntax-fehler.de>2017-09-09 16:25:37 +0200
committermakefu <github@syntax-fehler.de>2017-09-09 16:25:37 +0200
commitca7a1304541aad960fc2664d740e7c07eb794695 (patch)
treeb3a6b644ebcc3a27688bcbdbfe44f1339386837f /krebs/3modules/newsbot-js.nix
parent54feede990f042cc75a240dab50ad2016ed4c9ec (diff)
parent5067cc312e32b47862a8c02455bb2cd8f89a48a0 (diff)
Merge remote-tracking branch 'lass/master'
Diffstat (limited to 'krebs/3modules/newsbot-js.nix')
-rw-r--r--krebs/3modules/newsbot-js.nix135
1 files changed, 72 insertions, 63 deletions
diff --git a/krebs/3modules/newsbot-js.nix b/krebs/3modules/newsbot-js.nix
index dd3e5647a..d372081ee 100644
--- a/krebs/3modules/newsbot-js.nix
+++ b/krebs/3modules/newsbot-js.nix
@@ -6,51 +6,59 @@ let
cfg = config.krebs.newsbot-js;
+ enable = cfg != {};
+
out = {
options.krebs.newsbot-js = api;
- config = mkIf cfg.enable imp;
+ config = mkIf enable imp;
};
- api = {
- enable = mkEnableOption "Enable krebs newsbot";
- package = mkOption {
- type = types.package;
- default = pkgs.newsbot-js;
- description = "newsbot package to use";
- };
- ircServer = mkOption {
- type = types.str;
- default = "echelon.retiolum";
- description = "to which server the bot should connect";
- };
- channel = mkOption {
- type = types.str;
- default = "#news";
- description = "post the news in this channel";
- };
- masterNick = mkOption {
- type = types.str;
- default = "knews";
- description = "nickname of the master bot";
- };
- feeds = mkOption {
- type = types.path;
- description = ''
- file with feeds to post
- format:
- $nick|$feedURI
- '';
- };
- urlShortenerHost = mkOption {
- type = types.str;
- default = "echelon";
- description = "what server to use for url shortening, host";
- };
- urlShortenerPort = mkOption {
- type = types.str;
- default = "80";
- description = "what server to use for url shortening, port";
- };
+ api = mkOption {
+ type = types.attrsOf (types.submodule ({ config, ... }: {
+ options = {
+ enable = mkEnableOption "Enable krebs newsbot" // { default = true; };
+
+ channel = mkOption {
+ type = types.str;
+ default = "#${config._module.args.name}";
+ description = "post the news in this channel";
+ };
+ feeds = mkOption {
+ type = types.path;
+ description = ''
+ file with feeds to post
+ format:
+ $nick|$feedURI
+ '';
+ };
+ ircServer = mkOption {
+ type = types.str;
+ default = "localhost";
+ description = "to which server the bot should connect";
+ };
+ masterNick = mkOption {
+ type = types.str;
+ default = config._module.args.name;
+ description = "nickname of the master bot";
+ };
+ package = mkOption {
+ type = types.package;
+ default = pkgs.newsbot-js;
+ description = "newsbot package to use";
+ };
+ urlShortenerHost = mkOption {
+ type = types.str;
+ default = "go";
+ description = "what server to use for url shortening, host";
+ };
+ urlShortenerPort = mkOption {
+ type = types.str;
+ default = "80";
+ description = "what server to use for url shortening, port";
+ };
+ };
+ }));
+ default = {};
};
imp = {
@@ -61,32 +69,33 @@ let
home = "/var/empty";
};
- systemd.services.newsbot-js = {
- description = "krebs newsbot";
- after = [ "network.target" ];
- wantedBy = [ "multi-user.target" ];
+ systemd.services = mapAttrs' (name: newsbot:
+ nameValuePair "newsbot-${name}" {
+ after = [ "network.target" ];
+ wantedBy = [ "multi-user.target" ];
- path = with pkgs; [
- newsbot-js
- ];
+ path = with pkgs; [
+ newsbot-js
+ ];
- environment = {
- irc_server = cfg.ircServer;
- master_nick = cfg.masterNick;
- news_channel = cfg.channel;
- feeds_file = cfg.feeds;
- url_shortener_host = cfg.urlShortenerHost;
- url_shortener_port = cfg.urlShortenerPort;
- };
+ environment = {
+ irc_server = newsbot.ircServer;
+ master_nick = newsbot.masterNick;
+ news_channel = newsbot.channel;
+ feeds_file = newsbot.feeds;
+ url_shortener_host = newsbot.urlShortenerHost;
+ url_shortener_port = newsbot.urlShortenerPort;
+ };
- restartIfChanged = true;
+ restartIfChanged = true;
- serviceConfig = {
- User = "newsbot-js";
- Restart = "always";
- ExecStart = "${cfg.package}/bin/newsbot";
- };
- };
+ serviceConfig = {
+ User = "newsbot-js";
+ Restart = "always";
+ ExecStart = "${newsbot.package}/bin/newsbot";
+ };
+ }
+ ) cfg;
};
in out