Syncthing (#47)

This commit is contained in:
Patrick Stevens
2025-10-12 11:05:01 +01:00
committed by GitHub
parent 7a2f9017d0
commit 17bfb62adc
3 changed files with 47 additions and 0 deletions

View File

@@ -105,6 +105,7 @@ type WellKnownSubdomain =
| PureGym
| Whisper
| Robocop
| Syncthing
override this.ToString () =
match this with
@@ -119,6 +120,7 @@ type WellKnownSubdomain =
| WellKnownSubdomain.PureGym -> "puregym"
| WellKnownSubdomain.Whisper -> "whisper"
| WellKnownSubdomain.Robocop -> "robocop"
| WellKnownSubdomain.Syncthing -> "syncthing"
static member Parse (s : string) =
match s with
@@ -133,6 +135,7 @@ type WellKnownSubdomain =
| "puregym" -> WellKnownSubdomain.PureGym
| "whisper" -> WellKnownSubdomain.Whisper
| "robocop" -> WellKnownSubdomain.Robocop
| "syncthing" -> WellKnownSubdomain.Syncthing
| _ -> failwith $"Failed to deserialise: {s}"

View File

@@ -9,6 +9,7 @@ in {
./sops.nix
./apps/apps.nix
./radicale/radicale-config.nix
./syncthing/syncthing-config.nix
./gitea/gitea-config.nix
./miniflux/miniflux.nix
./userconfig.nix
@@ -48,6 +49,8 @@ in {
services.apps-config.domain = userConfig.domain;
# services.whisper-config.domain = userConfig.domain;
# services.whisper-config.subdomain = "whisper";
services.syncthing-config.subdomain = "syncthing";
services.syncthing-config.domain = userConfig.domain;
services.journald.extraConfig = "SystemMaxUse=100M";

View File

@@ -0,0 +1,41 @@
{
pkgs,
lib,
config,
...
}: {
options = {
services.syncthing-config = {
domain = lib.mkOption {
type = lib.types.str;
example = "example.com";
description = lib.mdDoc "Top-level domain to configure";
};
subdomain = lib.mkOption {
type = lib.types.str;
example = "syncthing";
description = lib.mdDoc "Subdomain in which to put Syncthing";
};
port = lib.mkOption {
type = lib.types.port;
description = lib.mdDoc "Syncthing localhost port";
default = 8384;
};
};
};
config = let
filesystem_folder = "/preserve/syncthing/";
in {
services.syncthing = {
enable = true;
user = "syncthing";
dataDir = "${filesystem_folder}/data"; # Default folder for new synced folders
configDir = "${filesystem_folder}/config"; # Folder for Syncthing's settings and keys
openDefaultPorts = true;
};
systemd.services.syncthing.serviceConfig.ReadWritePaths = [filesystem_folder];
systemd.tmpfiles.rules = ["d ${filesystem_folder} 0750 syncthing syncthing -"];
};
}