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 dac1863d..d6d42ca1 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 From f2e4142dff1c20857437d821db5006348df0ba56 Mon Sep 17 00:00:00 2001 From: lassulus Date: Mon, 5 Jun 2023 19:52:52 +0200 Subject: cal: use radicale with git sync --- krebs/2configs/cal.nix | 127 ++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 105 insertions(+), 22 deletions(-) (limited to 'krebs/2configs') diff --git a/krebs/2configs/cal.nix b/krebs/2configs/cal.nix index 90093e8e..15f0027b 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 = "${}"; + }; + + security.sudo.extraConfig = '' + git ALL=(radicale) NOPASSWD: ${pushCal} + ''; } -- cgit v1.2.3 From ab0812fa5ac2a3d378a3eaa155ef734aa2a3b196 Mon Sep 17 00:00:00 2001 From: lassulus Date: Sat, 10 Jun 2023 22:38:40 +0200 Subject: reaktor2: use new bing api --- krebs/2configs/reaktor2.nix | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'krebs/2configs') diff --git a/krebs/2configs/reaktor2.nix b/krebs/2configs/reaktor2.nix index 67c2dd4c..45ff61ba 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"; -- cgit v1.2.3