NixOS/system/services/syncthing.nix

187 lines
5.4 KiB
Nix
Raw Normal View History

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 = {
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"
];
};
"/nas/Syncthing/Sync/VPN" = {
label = "OpenVPN";
id = "OpenVPN";
devices = [
"s20fe"
"work-laptop"
];
};
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;
devices = [
"s20fe"
"work-laptop"
];
2024-06-21 21:48:50 +07:00
};
2024-07-04 14:08:13 +07:00
"/nas/photos/mama" = {
label = "Camera Mama";
id = "sm-s906e_8dch-photos";
devices = [ "samsung-s22-mama" ];
};
"/nas/photos/tigor" = {
label = "Camera Tigor";
id = "sm-g780f_yjwa-photos";
devices = [ "s20fe" ];
};
"/nas/Syncthing/Sync/Onyx-Notes" = {
2024-07-04 14:08:13 +07:00
label = "Onyx Notes";
id = "Onyx-Notes";
devices = [ "onyx" ];
};
"/nas/Syncthing/Sync/Japanese-Learning-Materials" = {
label = "Japanese Learning Materials";
id = "Japanese-Learning-Materials";
devices = [
"s20fe"
"work-laptop"
];
};
2024-07-22 19:54:40 +07:00
"/nas/Syncthing/Sync/Memes" = {
label = "Memes";
id = "Memes";
devices = [
"s20fe"
"work-laptop"
];
};
2024-07-11 13:18:37 +07:00
"/nas/EmuDeck" = {
label = "EmuDeck";
id = "EmuDeck";
devices = [
"steam-deck"
"windows"
"living-room-system"
2024-07-11 13:18:37 +07:00
];
};
2024-07-24 09:50:06 +07:00
"/nas/Syncthing/Sync/sops" = {
label = "Sops";
id = "Sops";
devices = [
"s20fe"
"work-laptop"
"windows"
];
};
2024-08-20 22:17:18 +07:00
"/nas/Syncthing/Sync/Music" = {
label = "Music";
id = "Music";
devices = [
"s20fe"
"work-laptop"
"windows"
"living-room-system"
];
};
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-07-11 13:18:37 +07:00
steam-deck = {
name = "Steam Deck";
id = "6SOR4SU-MVT2XIS-4J6IGVP-LITFLDB-ZH6LA7T-PUSQK26-P6RVWZ7-YB7P4AX";
};
living-room-system = {
name = "Living Room System";
id = "63W5VTT-X6R6WOC-LMQEXM7-6PCUYLX-UONPYFB-UYM2OGN-2TJ47HG-66TSCQC";
};
2024-06-20 20:28:21 +07:00
};
2024-06-14 10:04:29 +07:00
};
overrideFolders = true;
overrideDevices = true;
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
};
};
}