feat(syncthing): adding syncthing host to sobotka

This commit is contained in:
2025-09-06 13:49:24 +02:00
parent a11e4961e1
commit eefa14bd57
5 changed files with 92 additions and 2 deletions

View File

@@ -9,6 +9,11 @@
uid = 994;
gid = 993;
mounts = {
fast = "/mnt/user";
config = "/persist/opt/services";
};
unbound = {
enable = true;
};

View File

@@ -129,6 +129,7 @@
./server/lidarr
./server/radarr
./server/sonarr
./server/syncthing
./server/jellyseerr
./server/jellyfin
./server/podman

View File

@@ -9,7 +9,9 @@ let
in
{
options = {
home.services.syncthing.enable = mkEnableOption "Enables syncthing";
home.services.syncthing = {
enable = mkEnableOption "Enables syncthing";
};
};
config = mkIf cfg.enable {
services.syncthing = {

View File

@@ -11,6 +11,20 @@ in
{
options.server = {
enable = lib.mkEnableOption "The server services and configuration variables";
mounts.fast = lib.mkOption {
default = "/mnt/cache";
type = lib.types.path;
description = ''
Path to the 'fast' tier mount
'';
};
mounts.config = lib.mkOption {
default = "/persist/opt/services";
type = lib.types.path;
description = ''
Path to the service configuration files
'';
};
email = mkOption {
default = "";
type = types.str;
@@ -53,7 +67,6 @@ in
GID to run the server services as
'';
};
timeZone = lib.mkOption {
default = "Europe/Stockholm";
type = lib.types.str;
@@ -62,6 +75,7 @@ in
'';
};
};
config = lib.mkIf cfg.enable {
users = {
groups.${cfg.group} = {

View File

@@ -0,0 +1,68 @@
{
config,
lib,
...
}:
let
unit = "syncthing";
srv = config.server;
cfg = config.server.${unit};
dir = [
"${srv.mounts.config}/syncthing"
];
in
{
options.server.${unit} = {
enable = lib.mkEnableOption {
description = "Enable ${unit}";
};
url = lib.mkOption {
type = lib.types.str;
default = "${unit}.${srv.domain}";
};
homepage.name = lib.mkOption {
type = lib.types.str;
default = "Syncthing";
};
homepage.description = lib.mkOption {
type = lib.types.str;
default = "Continuous file synchronization program.";
};
homepage.icon = lib.mkOption {
type = lib.types.str;
default = "syncthing.svg";
};
homepage.category = lib.mkOption {
type = lib.types.str;
default = "Services";
};
};
config = lib.mkIf cfg.enable {
systemd.tmpfiles.rules = map (x: "d ${x} 0775 share share - -") dir;
networking.firewall = {
allowedTCPPorts = [
8384
22000
];
allowedUDPPorts = [
22000
21027
];
};
services.${unit} = {
enable = true;
user = srv.user;
group = srv.group;
overrideFolders = false;
overrideDevices = false;
dataDir = "${srv.mounts.fast}/Syncthing";
configDir = "${srv.mounts.config}/syncthing";
};
services.caddy.virtualHosts."${cfg.url}" = {
useACMEHost = srv.domain;
extraConfig = ''
reverse_proxy http://127.0.0.1:8384}
'';
};
};
}