2024-06-14 10:04:29 +07:00
|
|
|
{ config, lib, ... }:
|
|
|
|
let
|
|
|
|
cfg = config.profile.services.syncthing;
|
2024-06-20 20:28:21 +07:00
|
|
|
user = config.profile.user;
|
|
|
|
uid = toString user.uid;
|
|
|
|
gid = toString user.gid;
|
|
|
|
dataDir = "/nas/Syncthing";
|
2024-06-14 10:04:29 +07:00
|
|
|
inherit (lib) mkIf;
|
|
|
|
in
|
|
|
|
{
|
|
|
|
config = mkIf cfg.enable {
|
2024-06-20 20:28:21 +07:00
|
|
|
system.activationScripts.syncthing = ''
|
|
|
|
mkdir -p ${dataDir}
|
|
|
|
chown ${uid}:${gid} ${dataDir}
|
|
|
|
'';
|
2024-06-14 10:04:29 +07:00
|
|
|
services.caddy.virtualHosts."syncthing.tigor.web.id".extraConfig = ''
|
|
|
|
reverse_proxy 0.0.0.0:8384
|
|
|
|
'';
|
2024-06-20 20:28:21 +07:00
|
|
|
sops.secrets =
|
|
|
|
let
|
|
|
|
opts = { owner = user.name; sopsFile = ../../secrets/syncthing.yaml; };
|
|
|
|
in
|
|
|
|
{
|
|
|
|
"syncthing/server/key.pem" = opts;
|
|
|
|
"syncthing/server/cert.pem" = opts;
|
|
|
|
};
|
2024-06-14 10:04:29 +07:00
|
|
|
services.syncthing = {
|
|
|
|
enable = true;
|
2024-06-20 20:28:21 +07:00
|
|
|
key = config.sops.secrets."syncthing/server/key.pem".path;
|
|
|
|
cert = config.sops.secrets."syncthing/server/cert.pem".path;
|
2024-06-14 10:04:29 +07:00
|
|
|
settings = {
|
|
|
|
options.urAccepted = 1; # Allow anonymous usage reporting.
|
2024-06-20 20:28:21 +07:00
|
|
|
folders = {
|
|
|
|
"/nas/redmage/images/windows" = {
|
|
|
|
label = "Redmage/Windows";
|
|
|
|
id = "Redmage/Windows";
|
2024-06-20 22:27:31 +07:00
|
|
|
devices = [
|
|
|
|
"windows"
|
|
|
|
];
|
2024-06-20 20:28:21 +07:00
|
|
|
};
|
|
|
|
"/nas/redmage/images/laptop-kerja" = {
|
|
|
|
label = "Redmage/Laptop-Kerja";
|
|
|
|
id = "Redmage/Laptop-Kerja";
|
2024-06-21 21:48:50 +07:00
|
|
|
devices = [
|
|
|
|
"work-laptop"
|
|
|
|
];
|
2024-06-20 20:28:21 +07:00
|
|
|
};
|
|
|
|
"/nas/redmage/images/s20fe-sfw" = {
|
|
|
|
label = "Redmage/S20FE";
|
|
|
|
id = "Redmage/S20FE";
|
|
|
|
devices = [
|
|
|
|
"s20fe"
|
|
|
|
];
|
|
|
|
};
|
|
|
|
"/nas/Syncthing/Sync/Japanese-Homework" = {
|
|
|
|
label = "Japanese Homework";
|
|
|
|
id = "Japanese-Homework";
|
|
|
|
devices = [
|
|
|
|
"s20fe"
|
|
|
|
"onyx"
|
2024-06-20 22:27:31 +07:00
|
|
|
"windows"
|
2024-06-20 20:28:21 +07:00
|
|
|
];
|
|
|
|
};
|
|
|
|
"/nas/kavita/library/light-novels" = {
|
|
|
|
label = "Light Novels";
|
|
|
|
id = "Light-Novels";
|
|
|
|
devices = [
|
|
|
|
"onyx"
|
|
|
|
];
|
|
|
|
};
|
2024-06-21 21:48:50 +07:00
|
|
|
"/nas/Syncthing/Sync/VPN" = {
|
|
|
|
label = "OpenVPN";
|
|
|
|
id = "OpenVPN";
|
|
|
|
devices = lib.attrsets.mapAttrsToList (key: _value: key) config.services.syncthing.settings.devices;
|
2024-06-23 20:01:24 +07:00
|
|
|
};
|
|
|
|
"/nas/Syncthing/Sync/WireGuard" = {
|
|
|
|
label = "WireGuard";
|
|
|
|
id = "WireGuard";
|
|
|
|
devices = lib.attrsets.mapAttrsToList (key: _value: key) config.services.syncthing.settings.devices;
|
2024-06-21 21:48:50 +07:00
|
|
|
};
|
2024-06-20 20:28:21 +07:00
|
|
|
};
|
|
|
|
devices = {
|
|
|
|
s20fe = {
|
|
|
|
name = "Samsung S20FE";
|
|
|
|
id = "ASH4PGY-H2ANIMX-RJJRODR-AD6KH5X-632CAG2-5NCDSGN-I27XNAC-EMVL6A7";
|
|
|
|
};
|
|
|
|
onyx = {
|
|
|
|
name = "Onyx Note Air 3";
|
|
|
|
id = "FZMFBD5-5PS566H-XJGV3FO-NQVSMX5-3VHPS7V-SUT27WA-MXHFBYT-BDSS6AW";
|
|
|
|
};
|
2024-06-20 22:27:31 +07:00
|
|
|
windows = {
|
|
|
|
name = "Windows";
|
|
|
|
id = "FSTIYS6-REFXIJX-KPLYC4L-QSZO46L-RV3VTPZ-VWVTE7O-Y663OZN-RTKP3QI";
|
|
|
|
};
|
2024-06-21 21:48:50 +07:00
|
|
|
work-laptop = {
|
|
|
|
name = "Work Laptop";
|
|
|
|
id = "BOU76IK-5AE7ARF-ZQDFOTX-KWUQL22-SAGXBYG-B75JRZA-L4MCYPU-OYTY5AU";
|
2024-06-23 20:14:13 +07:00
|
|
|
};
|
|
|
|
samsung-s22-mama = {
|
|
|
|
name = "Samsung S22 Mama";
|
|
|
|
id = "5G2Q7XE-HILUI46-GWTE6P6-NJHAG3A-HSZKMAU-K5PBOKR-QN3IFQO-GX7KTQU";
|
2024-06-21 21:48:50 +07:00
|
|
|
};
|
2024-06-20 20:28:21 +07:00
|
|
|
};
|
2024-06-14 10:04:29 +07:00
|
|
|
};
|
2024-07-02 14:06:48 +07:00
|
|
|
overrideFolders = false;
|
|
|
|
overrideDevices = false;
|
2024-06-14 10:04:29 +07:00
|
|
|
openDefaultPorts = true;
|
|
|
|
guiAddress = "0.0.0.0:8384";
|
2024-06-20 20:28:21 +07:00
|
|
|
user = user.name;
|
|
|
|
dataDir = dataDir;
|
2024-06-14 10:04:29 +07:00
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|