From 84646ba41595e3410fdd38b9d27312b33d4474f7 Mon Sep 17 00:00:00 2001 From: makefu Date: Tue, 22 Aug 2017 10:59:49 +0200 Subject: newsbot-js module: add package option this will be used for the wiki-irc-bot to override the patchPhase --- krebs/3modules/newsbot-js.nix | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'krebs/3modules') diff --git a/krebs/3modules/newsbot-js.nix b/krebs/3modules/newsbot-js.nix index 2ff9a5ebb..dd3e5647a 100644 --- a/krebs/3modules/newsbot-js.nix +++ b/krebs/3modules/newsbot-js.nix @@ -13,6 +13,11 @@ let 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"; @@ -79,7 +84,7 @@ let serviceConfig = { User = "newsbot-js"; Restart = "always"; - ExecStart = "${pkgs.newsbot-js}/bin/newsbot"; + ExecStart = "${cfg.package}/bin/newsbot"; }; }; }; -- cgit v1.2.3 From 3704f9c3417fa6c909ba03ab779734e391e128d0 Mon Sep 17 00:00:00 2001 From: tv Date: Tue, 5 Sep 2017 22:58:25 +0200 Subject: krebs.announce-activation: init --- krebs/3modules/announce-activation.nix | 60 ++++++++++++++++++++++++++++++++++ krebs/3modules/default.nix | 1 + 2 files changed, 61 insertions(+) create mode 100644 krebs/3modules/announce-activation.nix (limited to 'krebs/3modules') diff --git a/krebs/3modules/announce-activation.nix b/krebs/3modules/announce-activation.nix new file mode 100644 index 000000000..5a3a788c2 --- /dev/null +++ b/krebs/3modules/announce-activation.nix @@ -0,0 +1,60 @@ +with import ; +{ config, pkgs, ... }: let + cfg = config.krebs.announce-activation; + announce-activation = pkgs.writeDash "announce-activation" '' + set -efu + message=$(${cfg.get-message}) + exec ${pkgs.irc-announce}/bin/irc-announce \ + ${shell.escape cfg.irc.server} \ + ${shell.escape (toString cfg.irc.port)} \ + ${shell.escape cfg.irc.nick} \ + ${shell.escape cfg.irc.channel} \ + "$message" + ''; + default-get-message = pkgs.writeDash "announce-activation-get-message" '' + set -efu + PATH=${makeBinPath [ + pkgs.coreutils + pkgs.gawk + pkgs.gnused + pkgs.nix + ]} + profile=/nix/var/nix/profiles/system + gen_info=$(nix-env -p "$profile" --list-generations | tail -1) + gen_no=$(echo "$gen_info" | awk '{print$1}') + pretty_name=$(sed -n '/^PRETTY_NAME=/{s/.*="//;s/"$//;p}' /etc/os-release) + echo "activating generation $gen_no $pretty_name" + ''; +in { + options.krebs.announce-activation = { + enable = mkEnableOption "announce-activation"; + get-message = mkOption { + default = default-get-message; + type = types.package; + }; + irc = { + # TODO rename channel to target? + channel = mkOption { + default = "#retiolum"; + type = types.str; # TODO types.irc-channel + }; + nick = mkOption { + default = config.krebs.build.host.name; + type = types.label; + }; + port = mkOption { + default = 6667; + type = types.int; + }; + server = mkOption { + default = "ni.r"; + type = types.hostname; + }; + }; + }; + config = mkIf cfg.enable { + system.activationScripts.announce-activation = '' + ${announce-activation} + ''; + }; +} diff --git a/krebs/3modules/default.nix b/krebs/3modules/default.nix index abb3d37eb..42df3f053 100644 --- a/krebs/3modules/default.nix +++ b/krebs/3modules/default.nix @@ -6,6 +6,7 @@ let out = { imports = [ + ./announce-activation.nix ./apt-cacher-ng.nix ./backup.nix ./bepasty-server.nix -- cgit v1.2.3 From 6218a259a9880368c71ecacddcf1e7c641bd5278 Mon Sep 17 00:00:00 2001 From: lassulus Date: Wed, 6 Sep 2017 09:50:39 +0200 Subject: rtorrent: track nginx changes --- krebs/3modules/rtorrent.nix | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) (limited to 'krebs/3modules') diff --git a/krebs/3modules/rtorrent.nix b/krebs/3modules/rtorrent.nix index d85518993..472accef9 100644 --- a/krebs/3modules/rtorrent.nix +++ b/krebs/3modules/rtorrent.nix @@ -1,4 +1,4 @@ -{ config, lib, pkgs, ... }: +{ config, lib, pkgs, options, ... }: with import ; let @@ -73,6 +73,15 @@ let # authentication also applies to rtorrent.rutorrent enable = mkEnableOption "rtorrent nginx web RPC"; + addr = mkOption { + type = types.addr4; + default = "0.0.0.0"; + description = '' + the address to listen on + default is 0.0.0.0 + ''; + }; + port = mkOption { type = types.nullOr types.int; description ='' @@ -290,7 +299,7 @@ let services.nginx.enable = mkDefault true; services.nginx.virtualHosts.rtorrent = { default = mkDefault true; - inherit (webcfg) basicAuth port; + inherit (webcfg) basicAuth; root = optionalString rucfg.enable webdir; locations = { @@ -310,7 +319,15 @@ let include ${pkgs.nginx}/conf/fastcgi.conf; ''; } ); - }; + # workaround because upstream nginx api changed + # TODO remove when nobody uses 17.03 anymore + } // (if hasAttr "port" (head options.services.nginx.virtualHosts.type.getSubModules).submodule.options then { + port = webcfg.port; + } else { + listen = [ + { inherit (webcfg) addr port; } + ]; + }); }; rutorrent-imp = { -- cgit v1.2.3 From 22f74186edca15d7169aaa63c8ebf6f6549d649b Mon Sep 17 00:00:00 2001 From: lassulus Date: Sat, 9 Sep 2017 00:09:04 +0200 Subject: newsbot-js: add multiple instances --- krebs/3modules/newsbot-js.nix | 135 ++++++++++++++++++++++-------------------- 1 file changed, 72 insertions(+), 63 deletions(-) (limited to 'krebs/3modules') 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 -- cgit v1.2.3 From e068fb6cfb4b809384c6dcbf3a340ed48710cdf2 Mon Sep 17 00:00:00 2001 From: lassulus Date: Sat, 9 Sep 2017 00:24:27 +0200 Subject: l hosts: adopt Mic92 user --- krebs/3modules/lass/default.nix | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'krebs/3modules') diff --git a/krebs/3modules/lass/default.nix b/krebs/3modules/lass/default.nix index 257268af2..7d386b40f 100644 --- a/krebs/3modules/lass/default.nix +++ b/krebs/3modules/lass/default.nix @@ -357,5 +357,9 @@ with import ; wine-mors = { pubkey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIEKfTIKmbe1RjX1fjAn//08363zAsI0CijWnaYyAC842"; }; + Mic92 = { + pubkey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIKbBp2dH2X3dcU1zh+xW3ZsdYROKpJd3n13ssOP092qE"; + mail = "joerg@higgsboson.tk"; + }; }; } -- cgit v1.2.3 From 7e4bac7bdf90dea26bf25399b22de8bd1b69b6e0 Mon Sep 17 00:00:00 2001 From: lassulus Date: Sat, 9 Sep 2017 00:25:18 +0200 Subject: l hosts: adopt turingmachine (Mic92) --- krebs/3modules/lass/default.nix | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'krebs/3modules') diff --git a/krebs/3modules/lass/default.nix b/krebs/3modules/lass/default.nix index 7d386b40f..4e2d6df99 100644 --- a/krebs/3modules/lass/default.nix +++ b/krebs/3modules/lass/default.nix @@ -321,6 +321,34 @@ with import ; }; }; }; + turingmachine = { + ci = false; + external = true; + nets = { + retiolum = { + ip4.addr = "10.243.29.168"; + ip6.addr = "42:4992:6a6d:600::1"; + aliases = [ + "turingmachine.r" + ]; + tinc.pubkey = '' + -----BEGIN RSA PUBLIC KEY----- + MIICCgKCAgEAxh+5HD1oAFTvMWEra2pYrA3HF8T4EnkP917lIUiuN7xUj7sawu0C + t1/1IfIlH9dbxgFe5CD/gXvokxHdovPTGVH11L+thZgq6hg/xbYvZAl76yLxj7t9 + 6+Ocac08TQZYMqWKShz5jqTVE/DLz4Cdy0Qk9sMJ1++OmH8jsWgK5BkogF99Gwf8 + ZiI0t3n3lCZsm3v592lveDcVIh6hjuCIvFVxc+7cOj0MKm1LxLWbCHZlUIE3he4g + nZu4XiYaE4Y2LicMs8zKehnQkkXrP1amT56SqUfbSnWR+HZc2+KjwRDI5BPeTS06 + 5WHwkQs0ScOn7vFZci3rElIc7vilu2eKGF1VLce9kXw9SU2RFciqavaEUXbwPnwT + 1WF35Ct+qIOP0rXoObm6mrsj7hJnlBPlVpb58/kTxLHMSHPzqQRbFZ35f6tZodJ1 + gRMKKEnMX8/VWm6TqLUIpFCCTZ5PH1fxaAnulHCxksK03UyfUOvExCTU4x8KS9fl + DIoLlV9PFBlAW8mTuIgRKYtHacsc31/5Tehcx0If09NuMFT9Qfl2/Q3p6QJomRFL + W5SCP9wx2ONhvZUkRbeihBiTN5/h3DepjOeNWd1DvE6K0Ag8SXMyBGtyKfer4ykW + OR0iCiRQQ5QBmNuJrBLRUyfoPqFUXBATT1SrRj8vzXO1TjTmANEMFD0CAwEAAQ== + -----END RSA PUBLIC KEY----- + ''; + }; + }; + }; }; users = { lass = { -- cgit v1.2.3