diff options
author | nin <nineinchnade@gmail.com> | 2017-09-14 22:57:46 +0200 |
---|---|---|
committer | nin <nineinchnade@gmail.com> | 2017-09-14 22:57:46 +0200 |
commit | 56054fe431aca35119df307f2098f823fc03d1e9 (patch) | |
tree | 052c12e402d95ea2bf9b4a8c466480e7d59bf3ce /krebs/3modules/announce-activation.nix | |
parent | 036bd54f3142ba05409b742a809c3082176e4596 (diff) | |
parent | de16ae2a12145901c3d9e2efef062b161b9448e3 (diff) |
Merge remote-tracking branch 'prism/master'
Diffstat (limited to 'krebs/3modules/announce-activation.nix')
-rw-r--r-- | krebs/3modules/announce-activation.nix | 60 |
1 files changed, 60 insertions, 0 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} + ''; + }; +} |