2019-01-27 02:34:47 +00:00
|
|
|
with import <stockholm/lib>;
|
|
|
|
{ config, pkgs, ... }:
|
|
|
|
|
|
|
|
let
|
2019-01-27 15:55:47 +00:00
|
|
|
#for shared state directory
|
2019-01-27 02:34:47 +00:00
|
|
|
stateDir = config.krebs.reaktor2.r.stateDir;
|
|
|
|
|
|
|
|
generators = pkgs.reaktor2-plugins.generators;
|
|
|
|
hooks = pkgs.reaktor2-plugins.hooks;
|
|
|
|
commands = pkgs.reaktor2-plugins.commands;
|
|
|
|
|
|
|
|
task = name: let
|
|
|
|
rcFile = builtins.toFile "taskrc" ''
|
|
|
|
confirmation=no
|
|
|
|
'';
|
|
|
|
in {
|
2020-06-23 07:53:21 +00:00
|
|
|
pattern = "^${name}-([a-z]+)(?::?\\s*(.*))?";
|
2019-01-27 15:55:47 +00:00
|
|
|
activate = "match";
|
|
|
|
command = 1;
|
|
|
|
arguments = [2];
|
2019-01-27 19:32:04 +00:00
|
|
|
env.TASKDATA = "${stateDir}/${name}";
|
2019-01-27 15:55:47 +00:00
|
|
|
commands = {
|
2019-01-27 19:32:04 +00:00
|
|
|
add.filename = pkgs.writeDash "${name}-task-add" ''
|
|
|
|
${pkgs.taskwarrior}/bin/task rc:${rcFile} add "$1"
|
|
|
|
'';
|
|
|
|
list.filename = pkgs.writeDash "${name}-task-list" ''
|
|
|
|
${pkgs.taskwarrior}/bin/task rc:${rcFile} export \
|
|
|
|
| ${pkgs.jq}/bin/jq -r '
|
|
|
|
.[] | select(.id != 0) | "\(.id) \(.description)"
|
|
|
|
'
|
|
|
|
'';
|
|
|
|
delete.filename = pkgs.writeDash "${name}-task-delete" ''
|
|
|
|
${pkgs.taskwarrior}/bin/task rc:${rcFile} delete "$1"
|
|
|
|
'';
|
|
|
|
done.filename = pkgs.writeDash "${name}-task-done" ''
|
|
|
|
${pkgs.taskwarrior}/bin/task rc:${rcFile} done "$1"
|
|
|
|
'';
|
2019-01-27 02:34:47 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
systemPlugin = {
|
|
|
|
plugin = "system";
|
|
|
|
config = {
|
|
|
|
workdir = stateDir;
|
|
|
|
hooks.JOIN = [
|
|
|
|
{
|
|
|
|
activate = "always";
|
|
|
|
command = {
|
|
|
|
filename =
|
|
|
|
"${pkgs.Reaktor.src}/reaktor/commands/tell-on_join";
|
|
|
|
env = {
|
|
|
|
PATH = makeBinPath [
|
|
|
|
pkgs.coreutils # XXX env, touch
|
|
|
|
pkgs.jq # XXX sed
|
|
|
|
pkgs.utillinux # XXX flock
|
|
|
|
];
|
|
|
|
state_file = "${stateDir}/tell.json";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|
|
|
|
];
|
|
|
|
hooks.PRIVMSG = [
|
|
|
|
{
|
2019-01-29 20:39:16 +00:00
|
|
|
pattern = "^bier bal(an(ce)?)?$";
|
2019-01-27 02:34:47 +00:00
|
|
|
activate = "match";
|
|
|
|
command = {
|
|
|
|
env = {
|
|
|
|
state_file = "${stateDir}/ledger";
|
|
|
|
};
|
2019-01-27 12:50:31 +00:00
|
|
|
filename = pkgs.writeDash "bier-balance" ''
|
2019-01-27 13:27:54 +00:00
|
|
|
${pkgs.hledger}/bin/hledger -f $state_file bal -N -O csv \
|
|
|
|
| ${pkgs.coreutils}/bin/tail +2 \
|
2019-07-15 16:22:35 +00:00
|
|
|
| ${pkgs.miller}/bin/mlr --icsv --opprint cat \
|
|
|
|
| ${pkgs.gnused}/bin/sed 's/^/the_/'
|
2019-01-27 02:34:47 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
}
|
|
|
|
{
|
2020-06-23 07:53:21 +00:00
|
|
|
pattern = ''^([\w-]*):?\s+([+-][1-9][0-9]*)\s+(\S+)$'';
|
2019-01-27 02:34:47 +00:00
|
|
|
activate = "match";
|
|
|
|
arguments = [1 2 3];
|
|
|
|
command = {
|
|
|
|
env = {
|
|
|
|
# TODO; get state as argument
|
|
|
|
state_file = "${stateDir}/ledger";
|
|
|
|
};
|
|
|
|
filename = pkgs.writeDash "ledger-add" ''
|
|
|
|
set -x
|
|
|
|
tonick=$1
|
|
|
|
amt=$2
|
|
|
|
unit=$3
|
|
|
|
printf '%s\n %s %d %s\n %s %d %s\n' "$(date -Id)" "$tonick" "$amt" "$unit" "$_from" "$(expr 0 - "''${amt#+}")" "$unit" >> $state_file
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
}
|
|
|
|
hooks.sed
|
|
|
|
(generators.command_hook {
|
|
|
|
inherit (commands) hello random-emoji nixos-version stockholm-issue;
|
|
|
|
tell = {
|
|
|
|
filename =
|
|
|
|
"${pkgs.Reaktor.src}/reaktor/commands/tell-on_privmsg";
|
|
|
|
env = {
|
|
|
|
PATH = makeBinPath [
|
|
|
|
pkgs.coreutils # XXX date, env
|
|
|
|
pkgs.jq # XXX sed
|
|
|
|
pkgs.utillinux # XXX flock
|
|
|
|
];
|
|
|
|
state_file = "${stateDir}/tell.txt";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
})
|
2019-01-27 15:55:47 +00:00
|
|
|
(task "agenda")
|
|
|
|
];
|
2019-01-27 02:34:47 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
in {
|
|
|
|
|
2019-04-23 18:05:03 +00:00
|
|
|
users.users.reaktor2 = {
|
|
|
|
uid = genid_uint31 "reaktor2";
|
|
|
|
home = stateDir;
|
|
|
|
};
|
|
|
|
|
2019-01-27 02:34:47 +00:00
|
|
|
krebs.reaktor2 = {
|
|
|
|
freenode = {
|
|
|
|
hostname = "irc.freenode.org";
|
|
|
|
nick = "reaktor2|krebs";
|
|
|
|
plugins = [
|
|
|
|
{
|
|
|
|
plugin = "register";
|
|
|
|
config = {
|
|
|
|
channels = [
|
|
|
|
"#krebs"
|
|
|
|
];
|
|
|
|
};
|
|
|
|
}
|
|
|
|
systemPlugin
|
|
|
|
];
|
2019-01-27 19:06:06 +00:00
|
|
|
username = "reaktor2";
|
2019-01-27 02:34:47 +00:00
|
|
|
};
|
|
|
|
r = {
|
|
|
|
nick = "reaktor2|krebs";
|
2019-01-29 20:39:16 +00:00
|
|
|
sendDelaySec = null;
|
2019-01-27 02:34:47 +00:00
|
|
|
plugins = [
|
|
|
|
{
|
|
|
|
plugin = "register";
|
|
|
|
config = {
|
|
|
|
channels = [
|
|
|
|
"#noise"
|
|
|
|
"#xxx"
|
|
|
|
];
|
|
|
|
};
|
|
|
|
}
|
|
|
|
systemPlugin
|
|
|
|
];
|
2019-01-27 19:06:06 +00:00
|
|
|
username = "reaktor2";
|
2019-01-27 02:34:47 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|