48ddc5ab

By: ananjiani <ananjiani@noreply.codeberg.org>

feat(syncthing): declare game-save peers instead of pairing by hand (#348)

## The problem

Save sync has never actually run. Every host declared the `game-saves` folder, but each one listed **only itself** as a device:

```
steammachine  -> 1 device (itself)
ammars-pc     -> 1 device (itself)
steamdeck     -> 1 device (itself)
theoden       -> 1 device (itself)
```

Pairing by hand would not have fixed it either. `services.syncthing.overrideDevices` **defaults to `true`** in both the Home Manager and NixOS modules:

> Whether to delete the devices which are not configured via the `devices` option. If set to `false`, devices added via the web interface will persist.

So any peer added through the web UI is deleted on the next activation. That is what the old *"Devices are paired via web UI"* comment was up against — it only held until the next switch.

## The change

Adds `lib/syncthing-hosts.nix` with the four device IDs, keyed by hostname, consumed from both call sites:

- `modules/dendritic/gaming.nix` — desktop, steamdeck, steammachine
- `hosts/servers/theoden/configuration.nix` — NixOS service

Each host filters out its own entry, because Syncthing must not be handed itself as a peer.

### Why a new `gaming.syncthing.device` option

The module cannot work out which host it is:

- Home Manager exposes no `networking.hostName`
- The workstation hosts use **standalone** HM (`homeConfigurations."ammar@ammars-pc"`), which evaluates with `nixosConfig = null`, so the NixOS hostname is not reachable either

So it is set explicitly per host, the same way `ludusavi.backupPath` already is.

### Why `overrideDevices = false`

Device IDs derive from each machine's TLS certificate in its Syncthing data directory, and are therefore **per-install**. A reinstalled host gets a new ID. With `overrideDevices = false`, declared peers stay enforced while a device re-paired by hand after a reinstall persists rather than being deleted.

## Caveat worth stating

These IDs cannot be mirrored in terraform the way `lib/hosts.nix` is, because they are per-install rather than assigned. `lib/syncthing-hosts.nix` documents how to re-read one:

```bash
grep -oE '<device id="[A-Z0-9-]+" name="[^"]*"' ~/.local/state/syncthing/config.xml
```

If a host is reinstalled, update that file.

## Verification

After deploying, each host should show three peers and the folder should be shared with all three:

```bash
ssh root@192.168.1.111 'sudo -u ammar syncthing cli config devices list'
ssh root@theoden.lan 'syncthing cli config devices list'
```

Then a real round trip: write a file under `~/Games/Saves/` on the desktop, confirm it reaches the Steam Machine and theoden.

Note the Steam Deck currently has `syncthing.service` **inactive**, so it will not sync until that host is deployed too.

Co-authored-by: Ammar <ammar.nanjiani@gmail.com>
Reviewed-on: https://codeberg.org/ananjiani/infra/pulls/348

Total

11m54s

Time to Start Worker time Duration Time to finish Idle
Config 0s 2s 2s 2s 0s
Eval 2s 4m41s 4m41s 4m43s 0s
Build 4m43s 11m54s 7m11s 11m54s 0s
Suite 0s 16m38s 11m54s 11m54s 1s

Timeline

Config Eval Build
0s1m2m3m4m5m6m7m8m9m10m11m