diff options
author | makefu <github@syntax-fehler.de> | 2017-09-06 11:12:24 +0200 |
---|---|---|
committer | makefu <github@syntax-fehler.de> | 2017-09-06 11:12:24 +0200 |
commit | 4399e8ee64864596d1a5062a78cf405e2c5d6221 (patch) | |
tree | 0bcc67e7d0f4ff22ca7e4840608f72015a49fbdd /krebs/3modules | |
parent | d12b4d86310ab56ac87f4ba768e49fd6423a9f37 (diff) | |
parent | 99ecdb4dab32d5a5044cd439a9ce639801d1398b (diff) |
Merge remote-tracking branch 'lass/master'
Diffstat (limited to 'krebs/3modules')
-rw-r--r-- | krebs/3modules/announce-activation.nix | 60 | ||||
-rw-r--r-- | krebs/3modules/default.nix | 1 | ||||
-rw-r--r-- | krebs/3modules/nin/default.nix | 5 | ||||
-rw-r--r-- | krebs/3modules/rtorrent.nix | 23 |
4 files changed, 85 insertions, 4 deletions
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 <stockholm/lib>; +{ 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 diff --git a/krebs/3modules/nin/default.nix b/krebs/3modules/nin/default.nix index d5d13cd1a..aab568352 100644 --- a/krebs/3modules/nin/default.nix +++ b/krebs/3modules/nin/default.nix @@ -3,7 +3,10 @@ with import <stockholm/lib>; { - hosts = mapAttrs (_: setAttr "owner" config.krebs.users.nin) { + hosts = mapAttrs (_: recursiveUpdate { + owner = config.krebs.users.nin; + ci = true; + }) { hiawatha = { cores = 2; nets = { 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 <stockholm/lib>; 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 = { |