syncthing: add workaround for infinite recursion on unstable

This commit is contained in:
lassulus 2023-05-24 17:39:54 +02:00
parent e3863bdf74
commit 9fe6e5bb4f

View File

@ -1,17 +1,21 @@
{ config, pkgs, ... }: with import <stockholm/lib>; let { options, config, pkgs, ... }: with import <stockholm/lib>; let
mk_peers = mapAttrs (n: v: { id = v.syncthing.id; }); mk_peers = mapAttrs (n: v: { id = v.syncthing.id; });
all_peers = filterAttrs (n: v: v.syncthing.id != null) config.krebs.hosts; 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; used_peers = filterAttrs (n: v: elem n used_peer_names) all_peers;
in { in {
services.syncthing = { services.syncthing = {
enable = true; enable = true;
configDir = "/var/lib/syncthing"; configDir = "/var/lib/syncthing";
devices = mk_peers used_peers;
key = toString <secrets/syncthing.key>; key = toString <secrets/syncthing.key>;
cert = toString <secrets/syncthing.cert>; cert = toString <secrets/syncthing.cert>;
}; # 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; boot.kernel.sysctl."fs.inotify.max_user_watches" = 524288;
} }