summaryrefslogtreecommitdiffstats
path: root/krebs
diff options
context:
space:
mode:
Diffstat (limited to 'krebs')
-rw-r--r--krebs/2configs/cal.nix127
-rw-r--r--krebs/2configs/reaktor2.nix5
-rw-r--r--krebs/5pkgs/simple/vicuna-chat/default.nix33
-rw-r--r--krebs/nixpkgs-unstable.json8
-rw-r--r--krebs/nixpkgs.json8
-rwxr-xr-xkrebs/update-nixpkgs.sh2
6 files changed, 150 insertions, 33 deletions
diff --git a/krebs/2configs/cal.nix b/krebs/2configs/cal.nix
index 90093e8eb..15f0027b3 100644
--- a/krebs/2configs/cal.nix
+++ b/krebs/2configs/cal.nix
@@ -1,33 +1,116 @@
-{ config, lib, pkgs, ... }:
-{
- users.users.testing = {
- uid = pkgs.stockholm.lib.genid_uint31 "testing";
- isNormalUser = true;
- openssh.authorizedKeys.keys = [
- config.krebs.users.xkey.pubkey
- config.krebs.users.lass.pubkey
- ];
- packages = [
- pkgs.calendar-cli
- pkgs.tmux
- ];
- };
+{ config, lib, pkgs, ... }: let
+
+ setupGit = ''
+ export PATH=${lib.makeBinPath [
+ pkgs.coreutils
+ pkgs.git
+ ]}
+ export GIT_SSH_COMMAND='${pkgs.openssh}/bin/ssh -i /var/lib/radicale/.ssh/id_ed25519'
+ repo='git@localhost:cal'
+ cd /var/lib/radicale/collections
+ if ! test -d .git; then
+ git init
+ git config user.name "radicale"
+ git config user.email "radicale@${config.networking.hostName}"
+ elif ! url=$(git config remote.origin.url); then
+ git remote add origin "$repo"
+ elif test "$url" != "$repo"; then
+ git remote set-url origin "$repo"
+ fi
+ cp ${pkgs.writeText "gitignore" ''
+ .Radicale.cache
+ ''} .gitignore
+ git add .gitignore
+ '';
- services.xandikos = {
+ pushCal = pkgs.writeDash "push_cal" ''
+ ${setupGit}
+ git fetch origin
+ git merge --ff-only origin/master || :
+ '';
+
+ pushCgit = pkgs.writeDash "push_cgit" ''
+ ${setupGit}
+ git push origin master
+ '';
+
+in {
+ services.radicale = {
enable = true;
- extraOptions = [
- "--autocreate"
- "--defaults"
- "--current-user-principal /krebs"
- "--dump-dav-xml"
- ];
+ rights = {
+ krebs = {
+ user = ".*";
+ collection = ".*";
+ permissions = "rRwW";
+ };
+ };
+ settings = {
+ auth.type = "none";
+ server.hosts = [
+ "0.0.0.0:5232"
+ "[::]:5232"
+ ];
+ storage.filesystem_folder = "/var/lib/radicale/collections";
+ storage.hook = "${pkgs.writers.writeDash "radicale-hook" ''
+ set -efu
+ ${setupGit}
+ ${pkgs.git}/bin/git add -A
+ (${pkgs.git}/bin/git diff --cached --quiet || ${pkgs.git}/bin/git commit -m "Changes by \"$1\"")
+ ${pushCgit}
+ ''} %(user)s";
+ };
};
services.nginx = {
enable = true;
virtualHosts = {
- "calendar.r".locations."/".proxyPass = "http://localhost:${toString config.services.xandikos.port}/";
+ "calendar.r".locations."/".proxyPass = "http://localhost:5232/";
+ };
+ };
+ krebs.git = {
+ enable = true;
+ cgit.settings = {
+ root-title = "krebs repos";
+ };
+ rules = with pkgs.stockholm.lib.git; [
+ {
+ user = [
+ {
+ name = "cal";
+ pubkey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGe1jtHaNFZKmWemWQVEGVYj+s4QGJaL9WYH+wokOZie";
+ }
+ ] ++ (lib.attrValues config.krebs.users);
+ repo = [ config.krebs.git.repos.cal ];
+ perm = push ''refs/heads/master'' [ create merge ];
+ }
+ ];
+ repos.cal = {
+ public = true;
+ name = "cal";
+ hooks = {
+ post-receive = ''
+ ${pkgs.git-hooks.irc-announce {
+ channel = "#xxx";
+ refs = [
+ "refs/heads/master"
+ ];
+ nick = config.networking.hostName;
+ server = "irc.r";
+ verbose = true;
+ }}
+ /run/wrappers/bin/sudo -S -u radicale ${pushCal}
+ '';
+ };
};
};
+ krebs.secret.files.calendar = {
+ path = "/var/lib/radicale/.ssh/id_ed25519";
+ owner = { name = "radicale"; };
+ source-path = "${<secrets/radicale.id_ed25519>}";
+ };
+
+ security.sudo.extraConfig = ''
+ git ALL=(radicale) NOPASSWD: ${pushCal}
+ '';
}
diff --git a/krebs/2configs/reaktor2.nix b/krebs/2configs/reaktor2.nix
index 67c2dd4cd..45ff61baf 100644
--- a/krebs/2configs/reaktor2.nix
+++ b/krebs/2configs/reaktor2.nix
@@ -77,7 +77,7 @@ let
if [ "$?" -ne 0 ]; then
report_error "$response"
else
- if ! text=$(printf '%s' "$response" | jq -er '.item.messages[1].text'); then
+ if ! text=$(printf '%s' "$response" | jq -er '.item.messages[-1].text'); then
echo "$_from: $(report_error "$response")"
exit 0
fi
@@ -85,7 +85,7 @@ let
echo "$_from: $text" | fold -s -w 426
printf '%s' "$response" |
- jq -r '[.item.messages[1].sourceAttributions[].seeMoreUrl] | to_entries[] | "[\(.key + 1)]: \(.value)"'
+ jq -r '[.item.messages[-1].sourceAttributions[].seeMoreUrl] | to_entries[] | "[\(.key + 1)]: \(.value)"'
fi
'';
};
@@ -158,6 +158,7 @@ let
'';
};
};
+
interrogate = {
pattern = "^!interrogate (.*)$";
activate = "match";
diff --git a/krebs/5pkgs/simple/vicuna-chat/default.nix b/krebs/5pkgs/simple/vicuna-chat/default.nix
new file mode 100644
index 000000000..11a11aabe
--- /dev/null
+++ b/krebs/5pkgs/simple/vicuna-chat/default.nix
@@ -0,0 +1,33 @@
+{ pkgs, ... }:
+pkgs.writers.writeDashBin "vicuna-chat" ''
+ set -efu
+
+ export PATH=${with pkgs; lib.makeBinPath [
+ coreutils
+ curl
+ jq
+ ]}
+
+ CONTEXT=''${CONTEXT:-$(date -Id)}
+ PROMPT=$*
+
+ if ! test -e "$CONTEXT"; then
+ echo -n 'null' > "$CONTEXT"
+ fi
+
+ add_to_context() {
+ jq -rc --argjson message "$1" '. + [$message]' "$CONTEXT" > "$CONTEXT.tmp"
+ mv "$CONTEXT.tmp" "$CONTEXT"
+ }
+
+ add_to_context "{\"role\": \"user\", \"content\": \"$PROMPT\"}"
+ response=$(
+ jq -nc --slurpfile context "$CONTEXT" '{
+ model: "vicuna-13b",
+ messages: $context[0],
+ }' |
+ curl -Ss http://vicuna.r/v1/chat/completions -H 'Content-Type: application/json' -d @-
+ )
+ add_to_context "$(jq -rcn --argjson response "$response" '$response.choices[0].message')"
+ jq -rcn --argjson response "$response" '$response.choices[0].message.content'
+''
diff --git a/krebs/nixpkgs-unstable.json b/krebs/nixpkgs-unstable.json
index 9b4622275..ea44e0c04 100644
--- a/krebs/nixpkgs-unstable.json
+++ b/krebs/nixpkgs-unstable.json
@@ -1,9 +1,9 @@
{
"url": "https://github.com/NixOS/nixpkgs",
- "rev": "7084250df3d7f9735087d3234407f3c1fc2400e3",
- "date": "2023-05-22T13:19:02+02:00",
- "path": "/nix/store/zgv3fzg2lywfqdrv4mghd62s9i6zxhrw-nixpkgs",
- "sha256": "0nkg8h5ix0sbjqb0gdj5124nbg2gd1nmyl1p14cvlg77fs7afld6",
+ "rev": "04af42f3b31dba0ef742d254456dc4c14eedac86",
+ "date": "2023-06-17T03:03:56+03:00",
+ "path": "/nix/store/5g6mwq41hn17rxrrn7rpdaxk9ca5znnb-nixpkgs",
+ "sha256": "130w72blrj4f08qdj2y44abfkrwhmkk9nq9zrhb9abndnpv85001",
"fetchLFS": false,
"fetchSubmodules": false,
"deepClone": false,
diff --git a/krebs/nixpkgs.json b/krebs/nixpkgs.json
index d4d9cc743..bf8858cd9 100644
--- a/krebs/nixpkgs.json
+++ b/krebs/nixpkgs.json
@@ -1,9 +1,9 @@
{
"url": "https://github.com/NixOS/nixpkgs",
- "rev": "a17f99dfcb9643200b3884ca195c69ae41d7f059",
- "date": "2023-05-23T18:09:00+02:00",
- "path": "/nix/store/2n82i65gv1y54xj3dplkvhfyc8rs1j90-nixpkgs",
- "sha256": "180ipicp351s99nvn9xvf5nzs5fzxhawfbykaijvaqj63siss13m",
+ "rev": "c7ff1b9b95620ce8728c0d7bd501c458e6da9e04",
+ "date": "2023-06-16T15:10:29+02:00",
+ "path": "/nix/store/q26lhs4mcd384gdljz4cnnx710f705m0-nixpkgs",
+ "sha256": "0bq722ick80qwg1k1zv1021b2x7mlwsxv10y999mh22gk7vdfmi7",
"fetchLFS": false,
"fetchSubmodules": false,
"deepClone": false,
diff --git a/krebs/update-nixpkgs.sh b/krebs/update-nixpkgs.sh
index 97c069d86..465548f44 100755
--- a/krebs/update-nixpkgs.sh
+++ b/krebs/update-nixpkgs.sh
@@ -3,7 +3,7 @@ dir=$(dirname $0)
oldrev=$(cat $dir/nixpkgs.json | jq -r .rev | sed 's/\(.\{7\}\).*/\1/')
nix-shell -p nix-prefetch-git --run 'nix-prefetch-git \
--url https://github.com/NixOS/nixpkgs \
- --rev refs/heads/nixos-22.11' \
+ --rev refs/heads/nixos-23.05' \
> $dir/nixpkgs.json
newrev=$(cat $dir/nixpkgs.json | jq -r .rev | sed 's/\(.\{7\}\).*/\1/')
git commit $dir/nixpkgs.json -m "nixpkgs: $oldrev -> $newrev"