fix(syncthing): Persist Syncthing state

Previously, the device ID would be lost and consequently regenerated on boot.
This means that previous connections will recognise it as a new, different
device.
This commit is contained in:
Madeleine Sydney
2025-02-15 13:28:03 -07:00
parent 84df241cfe
commit 1bdcc3ecbc
3 changed files with 77 additions and 42 deletions

View File

@@ -179,6 +179,8 @@ sydnix-cli is a command-line utility written in Clojure wrapping various sydnix-
** Emacs from scratch
*** TODO [#A] [[id:6141dc5c-2232-4bc0-9464-410c21135c86][Strategies]]
*** TODO Completions w/ [[https://github.com/minad/corfu][Corfu]]
*** TODO Overlay org-mode links with the domain name
@@ -231,10 +233,6 @@ If a comment immediately proceeds a sexp, open the new sexp /before/ the comment
*** DONE Evil operators like ~=~ should not move point
*** TODO Fix ~syd-forward-up-sexp~
*** TODO Fix defun text object
*** TODO ESC should immediately close minibuffer, even whilst in insert state
*** DONE Daemon

View File

@@ -18,6 +18,8 @@
./files.nix
];
xdg.enable = true;
sydnix = {
sops = {
enable = true;

View File

@@ -1,10 +1,15 @@
{ config, lib, pkgs, ... }:
let mutableSymlink = config.lib.file.mkOutOfStoreSymlink;
in {
in lib.mkMerge [
{
# TODO: Move to programs/age.nix.
xdg.configFile."sops/age/keys.txt".source =
mutableSymlink "/persist/vault/${config.home.username}/keys/melbourne";
}
{
### Some basic impermanence setup.
sydnix.impermanence = {
enable = true;
@@ -14,6 +19,9 @@ in {
"Documents"
"Videos"
"src"
# Should "org" be declared in emacs.nix? I don't think so. I
# conjecture that my org files are extremely valuable with or without
# Emacs.
"org"
".ssh"
{
@@ -23,8 +31,34 @@ in {
".passage"
];
};
}
{
### 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.
"${xdg-state-dir}/syncthing"
];
services.syncthing = {
enable = true;
settings = {
@@ -43,4 +77,5 @@ in {
};
};
};
}
}
]