refactor(syncthing): Refactor syncthing modules

This commit is contained in:
Madeleine Sydney
2025-03-10 15:16:47 -06:00
parent 4f5abf4826
commit 5f80bfc5c8
5 changed files with 187 additions and 121 deletions

View File

@@ -64,44 +64,20 @@ in lib.mkMerge [
{
### Syncthing
# TODO: sydnix.syncthing module
sydnix.impermanence.directories =
let xdg-state-dir =
config.home.statehome
or "${config.home.homeDirectory}/.local/state";
in [
# HACK: This relies on behaviour that is not explicitly defined by the
# Syncthing Home-manager module. We have to trust that $XDG_STATE_DIR,
# at the time of syncthing.service's start, does not differ from this
# value defined in Nix. Perhaps a PR to home-manager adding an option
# `services.syncthing.stateDir` would be good.
#
# If Syncthing ever breaks, make sure they didn't start using a different path:
# https://github.com/nix-community/home-manager/blob/master/modules/services/syncthing.nix
#
# Evidence for using this path is found at: (permalink)
# https://github.com/nix-community/home-manager/blob/6d3163aea47fdb1fe19744e91306a2ea4f602292/modules/services/syncthing.nix#L624
# Hack aside, this directory must be persisted to, at least
# 1. Preserve the device ID.
(lib.removePrefix config.home.homeDirectory "${xdg-state-dir}/syncthing")
];
services.syncthing = {
sydnix.syncthing = {
enable = true;
settings = {
overrideDevices = true;
overrideFolders = true;
devices = {
"guix-rebound".id =
"Q5B6LIV-5HQMWWV-XFQL5IT-PHP7PVE-XFWUVHK-F6WJ42C-OPMR4M7-GFNK3AG";
};
folders = {
"org" = {
path = "~/org";
devices = [ "guix-rebound" ];
ignorePerms = true;
};
includeDevices = [
"guix-rebound"
"deertopia"
];
directories = {
"org" = {
path = "~/org";
devices = [
"guix-rebound"
"deertopia"
];
ignorePerms = true;
};
};
};