This repository has no description
0

Configure Feed

Select the types of activity you want to include in your feed.

superconfig / 2configs / fysiirc.nix
1.8 kB 81 lines
1{ 2 config, 3 lib, 4 pkgs, 5 ... 6}: 7let 8 9 format-github-message = pkgs.writeDashBin "format-github-message" '' 10 set -efu 11 export PATH=${ 12 lib.makeBinPath [ 13 pkgs.jq 14 ] 15 } 16 INPUT=$(jq -c .) 17 if $(printf '%s' "$INPUT" | jq 'has("issue") or has("pull_request")'); then 18 ${write_to_irc} "$(printf '%s' "$INPUT" | jq -r ' 19 "\(.action): " + 20 "[\(.issue.title // .pull_request.title)] " + 21 "\(.comment.html_url // .issue.html_url // .pull_request.html_url) " 22 ')" 23 fi 24 ''; 25 26 write_to_irc = pkgs.writeDash "write_to_irc" '' 27 ${pkgs.curl}/bin/curl -fsSv http://localhost:44001 \ 28 -H content-type:application/json \ 29 -d "$(${pkgs.jq}/bin/jq -n \ 30 --arg text "$1" '{ 31 command:"PRIVMSG", 32 params:["#fysi",$text] 33 }' 34 )" 35 ''; 36 37in 38{ 39 krebs.iptables.tables.filter.INPUT.rules = [ 40 { 41 predicate = "-p tcp --dport 44002"; 42 target = "ACCEPT"; 43 } 44 ]; 45 krebs.reaktor2.fysiweb-github = { 46 hostname = "irc.libera.chat"; 47 port = "6697"; 48 useTLS = true; 49 nick = "fysiweb-github"; 50 API.listen = "inet://127.0.0.1:44001"; 51 plugins = [ 52 { 53 plugin = "register"; 54 config = { 55 channels = [ 56 "#fysi" 57 ]; 58 }; 59 } 60 ]; 61 }; 62 krebs.htgen.fysiweb-github = { 63 port = 44002; 64 user = { 65 name = "reaktor2-fysiweb-github"; 66 }; 67 script = ''. ${pkgs.writeDash "github-irc" '' 68 set -xefu 69 case "$Method $Request_URI" in 70 "POST /") 71 payload=$(head -c "$req_content_length") 72 printf '%s' "$payload" | ${format-github-message}/bin/format-github-message 73 printf 'HTTP/1.1 200 OK\r\n' 74 printf 'Connection: close\r\n' 75 printf '\r\n' 76 exit 77 ;; 78 esac 79 ''}''; 80 }; 81}