nix-config/hosts/heather/syncthing.nix
mikl 220d1f651c heather: replace k3s with docker+arion+caddy+syncthing
- remove k3s.nix (1.3GB overhead unjustified for single-node)
- add docker.nix (docker + arion CLI, mikl in docker group)
- add caddy.nix (edge proxy, TLS via ACME staging, host-based routing)
- add syncthing.nix (sync daemon + strelaysrv via systemd, /srv/syncthing)
- add arion-compose.nix (forgejo first, others stubbed as TODO)
- add arion flake input + nixos module
- default.nix: wire up arion project as systemd service (serviceName=heather)

Architecture: Caddy (host) terminates TLS, routes to host services (syncthing)
and docker containers (arion, 127.0.0.1:PORT). Named volumes everywhere except
silverbullet (bind /srv/syncthing/herbarium).
2026-07-12 12:23:05 +03:00

69 lines
3 KiB
Nix
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# heather — Syncthing (sync + relay) как NixOS-сервис.
#
# Заменяет syncthing@michaotic + strelaysrv с iscg-dev.
#
# - services.syncthing: sync daemon. dataDir = /srv/syncthing (синкается на
# устройства poppy/телефон). configDir = /var/lib/syncthing (state syncthing).
# - relayOptions.enable: strelaysrv, public relay на :22067 (relay) / :22070
# (status). Для устройств за NAT.
#
# GUI: 127.0.0.1:8384 (только localhost), Caddy проксирует на sync.iscg.dev
# с basicauth сверху (см. caddy.nix). Пароль GUI включить отдельно (syncthing
# сам требует при прослушивании не-localhost, но на localhost опционален —
# Caddy даёт внешний слой auth).
#
# /srv/syncthing/herbarium/ — silverbullet space (bind mount в контейнер,
# см. arion-compose.nix). syncthing sync'ает весь /srv/syncthing включая
# herbarium на устройства.
{ config, pkgs, lib, ... }:
{
services.syncthing = {
enable = true;
user = "mikl";
group = "users";
# Что синкается (файлы). /srv — FHS для service data.
dataDir = "/srv/syncthing";
# State syncthing (config, certs, index). Не синкается.
configDir = "/var/lib/syncthing";
# Открывает firewall порты 22000 (sync). firewall выключен на heather
# (полагаемся на YC SG), но флаг для консистентности.
openDefaultPorts = true;
# GUI только на localhost — Caddy проксирует снаружи.
guiAddress = "127.0.0.1:8384";
# НЕ override devices/folders из nix — конфигурим через GUI/API.
# overrideDevices/overrideFolders = false (default) = nix не трогает то,
# что добавлено через GUI. Иначе nix бы их стирал при rebuild.
overrideDevices = false;
overrideFolders = false;
};
# strelaysrv: public relay для syncthing-устройств за NAT.
# Порты 22067 (relay) и 22070 (status).
# NixOS-модуля syncthing не управляет strelaysrv — поднимаем вручную через
# systemd, пакет syncthing-relay (strelaysrv binary).
systemd.services.syncthing-relay = {
description = "Syncthing Relay Server (strelaysrv)";
after = [ "network.target" ];
wantedBy = [ "multi-user.target" ];
serviceConfig = {
ExecStart = "${pkgs.syncthing-relay}/bin/strelaysrv";
Restart = "on-failure";
User = "mikl";
Group = "users";
# strelaysrv пишет ключи/статус в CWD — рабочая директория.
WorkingDirectory = "/var/lib/syncthing-relay";
StateDirectory = "syncthing-relay";
};
};
# /srv/syncthing создаём, права mikl:users (syncthing работает от mikl).
systemd.tmpfiles.rules = [
"d /srv/syncthing 0755 mikl users -"
];
}