From d39c0b2d18ea48a824b37d58746151b77451e0e8 Mon Sep 17 00:00:00 2001 From: lassulus Date: Fri, 5 May 2023 01:50:19 +0200 Subject: reaktor2: add bing-img --- krebs/2configs/reaktor2.nix | 47 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) (limited to 'krebs/2configs') diff --git a/krebs/2configs/reaktor2.nix b/krebs/2configs/reaktor2.nix index 0a5031415..de1e01a35 100644 --- a/krebs/2configs/reaktor2.nix +++ b/krebs/2configs/reaktor2.nix @@ -90,6 +90,52 @@ let }; }; + bing-img = { + pattern = "!bing-img (.*)$"; + activate = "match"; + arguments = [1]; + timeoutSec = 1337; + command = { + filename = pkgs.writeDash "bing-img" '' + set -efu + report_error() { + printf '%s' "$*" | + curl -Ss http://p.r --data-binary @- | + tail -1 | + echo "error $(cat)" + exit 0 + } + export PATH=${makeBinPath [ + pkgs.dash + pkgs.coreutils + pkgs.curl + pkgs.findutils + pkgs.jq + ]} + response=$(printf '%s' "$*" | + curl -SsG http://bing-gpt.r/api/images --data-urlencode 'prompt@-' + ) + if [ "$?" -ne 0 ]; then + report_error "$response" + else + if ! text=$( + printf '%s' "$response" | + jq -er '.[].url' + ); then + echo "$_from: $(report_error "$response")" + exit 0 + fi + echo "$text" | + xargs -I {} dash -c 'curl -Ss {} | + curl -Ss https://p.krebsco.de --data-binary @- | + tail -1' | + tr '\n' ' ' | + echo "$_from: $(cat)" + fi + ''; + }; + }; + confuse = { pattern = "!confuse (.*)$"; activate = "match"; @@ -362,6 +408,7 @@ let bedger-add bedger-balance bing + bing-img hooks.sed interrogate say -- cgit v1.2.3 From df09f8293f326235d417ec750edf05298ba468de Mon Sep 17 00:00:00 2001 From: lassulus Date: Sun, 14 May 2023 19:56:47 +0200 Subject: reaktor2 bing: split lines after 426 chars --- krebs/2configs/reaktor2.nix | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'krebs/2configs') diff --git a/krebs/2configs/reaktor2.nix b/krebs/2configs/reaktor2.nix index de1e01a35..67c2dd4cd 100644 --- a/krebs/2configs/reaktor2.nix +++ b/krebs/2configs/reaktor2.nix @@ -81,7 +81,8 @@ let echo "$_from: $(report_error "$response")" exit 0 fi - printf '%s' "$text" | echo "$_from: $(cat)" + # value seems to be 512 - overhead + echo "$_from: $text" | fold -s -w 426 printf '%s' "$response" | jq -r '[.item.messages[1].sourceAttributions[].seeMoreUrl] | to_entries[] | "[\(.key + 1)]: \(.value)"' -- cgit v1.2.3 From 9fe6e5bb4f320876bff02bc75c51050d16593ad0 Mon Sep 17 00:00:00 2001 From: lassulus Date: Wed, 24 May 2023 17:39:54 +0200 Subject: syncthing: add workaround for infinite recursion on unstable --- krebs/2configs/syncthing.nix | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'krebs/2configs') diff --git a/krebs/2configs/syncthing.nix b/krebs/2configs/syncthing.nix index dac1863d5..d6d42ca11 100644 --- a/krebs/2configs/syncthing.nix +++ b/krebs/2configs/syncthing.nix @@ -1,17 +1,21 @@ -{ config, pkgs, ... }: with import ; let +{ options, config, pkgs, ... }: with import ; let mk_peers = mapAttrs (n: v: { id = v.syncthing.id; }); all_peers = filterAttrs (n: v: v.syncthing.id != null) config.krebs.hosts; - used_peer_names = unique (flatten (mapAttrsToList (n: v: v.devices) config.services.syncthing.declarative.folders)); + used_peer_names = unique (filter isString (flatten (mapAttrsToList (n: v: v.devices) config.services.syncthing.folders))); used_peers = filterAttrs (n: v: elem n used_peer_names) all_peers; in { services.syncthing = { enable = true; configDir = "/var/lib/syncthing"; - devices = mk_peers used_peers; key = toString ; cert = toString ; - }; + # workaround for infinite recursion on unstable, remove in 23.11 + } // (if builtins.hasAttr "settings" options.services.syncthing then + { settings.devices = mk_peers used_peers; } + else + { devices = mk_peers used_peers; } + ); boot.kernel.sysctl."fs.inotify.max_user_watches" = 524288; } -- cgit v1.2.3