summaryrefslogtreecommitdiffstats
path: root/krebs/5pkgs/simple
diff options
context:
space:
mode:
authorjeschli <jeschli@gmail.com>2019-01-29 19:17:43 +0100
committerjeschli <jeschli@gmail.com>2019-01-29 19:17:43 +0100
commit924c8fb748a92720c75750cee528ac2f4b7c5c8e (patch)
tree1a3b956f7f8527e533040cee1138810fe304bbc9 /krebs/5pkgs/simple
parent06b6454af78e8236a67d69cab94f62c32054be47 (diff)
parente64bbd8d6864e21f9e7b6b9a11cf95c976bdc109 (diff)
Merge branch 'master' of prism.r:stockholm
Diffstat (limited to 'krebs/5pkgs/simple')
-rw-r--r--krebs/5pkgs/simple/Reaktor/default.nix6
-rw-r--r--krebs/5pkgs/simple/Reaktor/plugins.nix68
-rwxr-xr-x[-rw-r--r--]krebs/5pkgs/simple/Reaktor/scripts/random-emoji.sh2
-rwxr-xr-x[-rw-r--r--]krebs/5pkgs/simple/Reaktor/scripts/random-issue.sh0
-rwxr-xr-x[-rw-r--r--]krebs/5pkgs/simple/Reaktor/scripts/sed-plugin.py2
-rwxr-xr-x[-rw-r--r--]krebs/5pkgs/simple/Reaktor/scripts/shack-correct.sh0
-rw-r--r--krebs/5pkgs/simple/much/cabal.nix28
-rw-r--r--krebs/5pkgs/simple/much/default.nix3
-rw-r--r--krebs/5pkgs/simple/reaktor2-plugins.nix106
9 files changed, 134 insertions, 81 deletions
diff --git a/krebs/5pkgs/simple/Reaktor/default.nix b/krebs/5pkgs/simple/Reaktor/default.nix
index 3ef9ffb7d..a88db6379 100644
--- a/krebs/5pkgs/simple/Reaktor/default.nix
+++ b/krebs/5pkgs/simple/Reaktor/default.nix
@@ -2,7 +2,7 @@
python3Packages.buildPythonPackage rec {
name = "Reaktor-${version}";
- version = "0.6.2";
+ version = "0.7.0";
doCheck = false;
@@ -13,8 +13,8 @@ python3Packages.buildPythonPackage rec {
src = fetchFromGitHub {
owner = "krebs";
repo = "Reaktor";
- rev = version;
- sha256 = "0h8pj0x9b5fnxddwrc0f63rxd3275v5phmjc0fv4kiwlzvbcxj6m";
+ rev = "v${version}";
+ sha256 = "12yy06vk0smjs0rmahrn2kd4bcdh1yjw1fz6rifw6nmgx889d9hj";
};
meta = {
homepage = http://krebsco.de/;
diff --git a/krebs/5pkgs/simple/Reaktor/plugins.nix b/krebs/5pkgs/simple/Reaktor/plugins.nix
index 6f59ad1de..1b19a1178 100644
--- a/krebs/5pkgs/simple/Reaktor/plugins.nix
+++ b/krebs/5pkgs/simple/Reaktor/plugins.nix
@@ -146,58 +146,36 @@ rec {
'';
});
- taskrcFile = builtins.toFile "taskrc" ''
- confirmation=no
- '';
-
- task-add = buildSimpleReaktorPlugin "task-add" {
- pattern = "^task-add: (?P<args>.*)$$";
- script = pkgs.writeDash "task-add" ''
- ${pkgs.taskwarrior}/bin/task rc:${taskrcFile} add "$*"
- '';
- };
-
- task-list = buildSimpleReaktorPlugin "task-list" {
- pattern = "^task-list";
- script = pkgs.writeDash "task-list" ''
- ${pkgs.taskwarrior}/bin/task rc:${taskrcFile} export | ${pkgs.jq}/bin/jq -r '.[] | select(.id != 0) | "\(.id) \(.description)"'
- '';
- };
-
- task-delete = buildSimpleReaktorPlugin "task-delete" {
- pattern = "^task-delete: (?P<args>.*)$$";
- script = pkgs.writeDash "task-delete" ''
- ${pkgs.taskwarrior}/bin/task rc:${taskrcFile} delete "$*"
- '';
- };
-
- task-done = buildSimpleReaktorPlugin "task-done" {
- pattern = "^task-done: (?P<args>.*)$$";
- script = pkgs.writeDash "task-done" ''
- ${pkgs.taskwarrior}/bin/task rc:${taskrcFile} done "$*"
- '';
- };
-
- todo = name: {
- add = buildSimpleReaktorPlugin "${name}-add" {
+ task = name: let
+ rcFile = builtins.toFile "taskrc" ''
+ confirmation=no
+ '';
+ in {
+ add = buildSimpleReaktorPlugin "${name}-task-add" {
pattern = "^${name}-add: (?P<args>.*)$$";
script = pkgs.writeDash "${name}-add" ''
- echo "$*" >> ${name}-todo
- echo "added ${name} todo"
+ TASKDATA=$HOME/${name} ${pkgs.taskwarrior}/bin/task rc:${rcFile} add "$*"
'';
};
- delete = buildSimpleReaktorPlugin "${name}-delete" {
+
+ list = buildSimpleReaktorPlugin "task-list" {
+ pattern = "^${name}-list";
+ script = pkgs.writeDash "task-list" ''
+ TASKDATA=$HOME/${name} ${pkgs.taskwarrior}/bin/task rc:${rcFile} export | ${pkgs.jq}/bin/jq -r '.[] | select(.id != 0) | "\(.id) \(.description)"'
+ '';
+ };
+
+ delete = buildSimpleReaktorPlugin "task-delete" {
pattern = "^${name}-delete: (?P<args>.*)$$";
- script = pkgs.writeDash "${name}-delete" ''
- ${pkgs.gnugrep}/bin/grep -Fvxe "$*" ${name}-todo > ${name}-todo.tmp
- ${pkgs.coreutils}/bin/mv ${name}-todo.tmp ${name}-todo
- echo "removed ${name} todo: $*"
+ script = pkgs.writeDash "task-delete" ''
+ TASKDATA=$HOME/${name} ${pkgs.taskwarrior}/bin/task rc:${rcFile} delete "$*"
'';
};
- show = buildSimpleReaktorPlugin "${name}-show" {
- pattern = "^${name}-show$";
- script = pkgs.writeDash "${name}-show" ''
- ${pkgs.coreutils}/bin/cat ${name}-todo
+
+ done = buildSimpleReaktorPlugin "task-done" {
+ pattern = "^${name}-done: (?P<args>.*)$$";
+ script = pkgs.writeDash "task-done" ''
+ TASKDATA=$HOME/${name} ${pkgs.taskwarrior}/bin/task rc:${rcFile} done "$*"
'';
};
};
diff --git a/krebs/5pkgs/simple/Reaktor/scripts/random-emoji.sh b/krebs/5pkgs/simple/Reaktor/scripts/random-emoji.sh
index 386aa68b9..6f3dd4a3f 100644..100755
--- a/krebs/5pkgs/simple/Reaktor/scripts/random-emoji.sh
+++ b/krebs/5pkgs/simple/Reaktor/scripts/random-emoji.sh
@@ -1,5 +1,5 @@
#!/bin/sh
-curl http://emojicons.com/random -s | \
+curl -sS http://emojicons.com/random | \
grep data-text | \
sed -n 's/.*>\(.*\)<\/textarea>/\1/p' | \
head -n 1 | \
diff --git a/krebs/5pkgs/simple/Reaktor/scripts/random-issue.sh b/krebs/5pkgs/simple/Reaktor/scripts/random-issue.sh
index 5c47c6156..5c47c6156 100644..100755
--- a/krebs/5pkgs/simple/Reaktor/scripts/random-issue.sh
+++ b/krebs/5pkgs/simple/Reaktor/scripts/random-issue.sh
diff --git a/krebs/5pkgs/simple/Reaktor/scripts/sed-plugin.py b/krebs/5pkgs/simple/Reaktor/scripts/sed-plugin.py
index ecb03917b..4925b25bb 100644..100755
--- a/krebs/5pkgs/simple/Reaktor/scripts/sed-plugin.py
+++ b/krebs/5pkgs/simple/Reaktor/scripts/sed-plugin.py
@@ -46,7 +46,7 @@ if is_regex(line):
print('to many lines, skipped')
else:
if last.strip() != ret.strip():
- print("\x1b[1m{}\x1b[0m meant: {}".format(usr, ret.strip()))
+ print("\x02{}\x02 meant: {}".format(usr, ret.strip()))
if ret:
d[usr] = ret
diff --git a/krebs/5pkgs/simple/Reaktor/scripts/shack-correct.sh b/krebs/5pkgs/simple/Reaktor/scripts/shack-correct.sh
index d500b3cb3..d500b3cb3 100644..100755
--- a/krebs/5pkgs/simple/Reaktor/scripts/shack-correct.sh
+++ b/krebs/5pkgs/simple/Reaktor/scripts/shack-correct.sh
diff --git a/krebs/5pkgs/simple/much/cabal.nix b/krebs/5pkgs/simple/much/cabal.nix
deleted file mode 100644
index 09bc7b5df..000000000
--- a/krebs/5pkgs/simple/much/cabal.nix
+++ /dev/null
@@ -1,28 +0,0 @@
-{ mkDerivation, aeson, attoparsec, base, base64-bytestring
-, blaze-builder, blessings, bytestring, case-insensitive
-, containers, deepseq, directory, docopt, email-header, fetchgit
-, filepath, friendly-time, hyphenation, linebreak, old-locale
-, process, random, rosezipper, safe, scanner, split, stdenv
-, terminal-size, text, time, transformers, transformers-compat
-, unix, vector
-}:
-mkDerivation {
- pname = "much";
- version = "1.1.0";
- src = fetchgit {
- url = "http://cgit.ni.krebsco.de/much";
- sha256 = "1325554zymr1dd0clj8c5ygl70c791csvs0hz33jcfr6b8wysdrl";
- rev = "dfec37d848e11c00d9b7f03295af1fc7b0e83ef5";
- };
- isLibrary = false;
- isExecutable = true;
- executableHaskellDepends = [
- aeson attoparsec base base64-bytestring blaze-builder blessings
- bytestring case-insensitive containers deepseq directory docopt
- email-header filepath friendly-time hyphenation linebreak
- old-locale process random rosezipper safe scanner split
- terminal-size text time transformers transformers-compat unix
- vector
- ];
- license = stdenv.lib.licenses.mit;
-}
diff --git a/krebs/5pkgs/simple/much/default.nix b/krebs/5pkgs/simple/much/default.nix
deleted file mode 100644
index cf55eb537..000000000
--- a/krebs/5pkgs/simple/much/default.nix
+++ /dev/null
@@ -1,3 +0,0 @@
-{ haskellPackages, ... }:
-
-haskellPackages.callPackage ./cabal.nix {}
diff --git a/krebs/5pkgs/simple/reaktor2-plugins.nix b/krebs/5pkgs/simple/reaktor2-plugins.nix
new file mode 100644
index 000000000..48464c0b6
--- /dev/null
+++ b/krebs/5pkgs/simple/reaktor2-plugins.nix
@@ -0,0 +1,106 @@
+with import <stockholm/lib>;
+{ lib, pkgs, ... }:
+
+rec {
+ generators = {
+ command_hook = commands: {
+ pattern =
+ "^\\s*([0-9A-Za-z._][0-9A-Za-z._-]*)(?:\\s+(.*\\S))?\\s*$";
+ command = 1;
+ arguments = [2];
+ commands = commands;
+ };
+ };
+
+ commands = {
+
+ hello = {
+ filename = "${pkgs.Reaktor.src}/reaktor/commands/hello";
+ };
+
+ random-emoji = {
+ filename = <stockholm/krebs/5pkgs/simple/Reaktor/scripts/random-emoji.sh>;
+ env = {
+ PATH = makeBinPath (with pkgs; [ coreutils gnused gnugrep xmlstarlet wget ]);
+ };
+ };
+
+ nixos-version = {
+ filename = pkgs.writeDash "nixos-version" ''
+ . /etc/os-release
+ echo "$PRETTY_NAME"
+ '';
+ };
+
+ stockholm-issue = {
+ filename = <stockholm/krebs/5pkgs/simple/Reaktor/scripts/random-issue.sh>;
+ env = {
+ PATH = makeBinPath (with pkgs; [ coreutils git gnused haskellPackages.lentil ]);
+ origin = "http://cgit.gum/stockholm";
+ state_dir = "/tmp/stockholm-issue";
+ };
+ };
+
+ };
+
+ hooks = {
+
+ sed = {
+ activate = "always";
+ pattern = "^(.*)$";
+ arguments = [1];
+ command = {
+ env = {
+ PATH = makeBinPath (with pkgs; [ gnused ]);
+ state_dir = "/tmp";
+ };
+ filename = pkgs.writeDash "sed-plugin" ''
+ set -efu
+ exec ${pkgs.python3}/bin/python \
+ ${<stockholm/krebs/5pkgs/simple/Reaktor/scripts/sed-plugin.py>} "$@"
+ '';
+ };
+ };
+
+ shack-correct = {
+ activate = "match";
+ pattern = "^(.*Shack.*)$";
+ arguments = [1];
+ command.filename = <stockholm/krebs/5pkgs/simple/Reaktor/scripts/shack-correct.sh>;
+ };
+
+
+ url-title = {
+ #pattern = "^.*(http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\(\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+).*$";
+ pattern = "^.*(http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\(\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+).*$";
+ activate = "match";
+ arguments = [1];
+ command = {
+ filename = pkgs.writePython3 "url-title" { deps = with pkgs.python3Packages; [ beautifulsoup4 lxml ]; } ''
+ import cgi
+ import sys
+ import urllib.request
+ from bs4 import BeautifulSoup
+
+ try:
+ req = urllib.request.Request(sys.argv[1])
+ req.add_header('user-agent', 'Reaktor-url-title')
+ resp = urllib.request.urlopen(req)
+ if resp.headers['content-type'].find('text/html') >= 0:
+ soup = BeautifulSoup(resp.read(16000), "lxml")
+ title = soup.find('title').string
+
+ if len(title.split('\n')) > 5:
+ title = '\n'.join(title.split('\n')[:5])
+
+ print(title[:450])
+ else:
+ cd_header = resp.headers['content-disposition']
+ print(cgi.parse_header(cd_header)[1]['filename'])
+ except: # noqa: E722
+ pass
+ '';
+ };
+ };
+ };
+}