config/modules/services/syncthing/default.nix

294 lines
7.5 KiB
Nix
Raw Normal View History

2023-07-26 11:36:54 +03:00
{
config,
lib,
myData,
...
2024-07-29 15:39:54 +03:00
}:
let
2023-10-01 23:14:05 +03:00
cfg = config.mj.services.syncthing;
2023-09-18 12:38:17 +03:00
devices = {
"fwminex".id = "GKSUKZE-AOBQOWY-CNLZ2ZI-WNKATYE-MV4Y452-J3VCJ5C-EAANXRX-2P6EHA6";
2024-03-14 13:47:31 +02:00
"mtworx".id = "C72YA2S-PE5IGDZ-DCNFV7Y-I72BGZM-5L2OO7Y-4K5OTGZ-NILAS2V-BGSAUQW";
2023-09-18 12:38:17 +03:00
"mxp10".id = "LO54QZZ-5J3G62P-WUVM3MW-7J3VWHD-BG76TOQ-5S7PZSY-JU45K3I-X3ZL4AN";
"rzj-744P2PE".id = "UW6ISH2-NW6X6AW-BJR76TV-TV3BIGZ-PA5QH2M-YEF567T-IWMHKD5-P3XHHAH";
2024-06-16 15:30:35 +03:00
"sqq1-desk".id = "WJ5KGRS-AGDZ7SW-INIVWHR-Q4E5QX4-Y4TT2AK-QRJTOTL-2UHXX6O-5MUPGA2";
2023-09-18 12:46:46 +03:00
"vno1-vinc".id = "4W3S7R2-OWI6XO6-V4NMDNB-NTIETYP-QJSBQGA-WEIXPHR-WNZZ7R4-VT4COAR";
2024-08-05 18:48:52 +03:00
"vno1-gdrx".id = "XOZO6GL-MEH55QR-PTNRVHE-45PD3L2-SHP7XW6-VXKROQ5-F47U3AX-QQACLQP";
2023-09-18 12:47:51 +03:00
"vno2-irena".id = "VL2MA2E-ZDGVHYN-A3Q3EKU-7J625QM-FG7CNXY-UKDL563-MDRRIEG-XQDS3AW";
2024-03-23 19:50:52 +02:00
"v-kfire".id = "REEDZAL-KPLWARZ-466J4BR-H5UDI6D-UUA33QG-HPZHIMX-WNFLDGD-PJLTFQZ";
2024-03-23 21:33:26 +02:00
"a-kfire".id = "VIQF4QW-2OLBBIK-XWOIO4A-264J32R-BE4J4BT-WEJXMYO-MXQDQHD-SJ6MEQ7";
2023-09-18 12:38:17 +03:00
};
2023-09-18 12:13:09 +03:00
folders = {
Books = {
2024-07-29 15:39:54 +03:00
devices = [
2024-08-05 18:48:52 +03:00
"vno1-gdrx"
2024-07-29 15:39:54 +03:00
"fwminex"
"mxp10"
];
2023-09-18 12:13:09 +03:00
id = "8lk0n-mm63y";
label = "Books";
};
Mail = {
2024-08-05 18:48:52 +03:00
devices = [
"vno1-gdrx"
"fwminex"
];
id = "66fmz-x6f1a";
label = "Mail";
};
2023-09-18 12:13:09 +03:00
M-Active = {
2024-07-29 15:39:54 +03:00
devices = [
2024-08-05 18:48:52 +03:00
"vno1-gdrx"
2024-07-29 15:39:54 +03:00
"mxp10"
"fwminex"
"mtworx"
];
2023-09-18 12:13:09 +03:00
id = "f6fma-unkxq";
label = "M-Active";
2024-01-25 09:05:46 +02:00
versioning = {
type = "staggered";
params = {
cleanInterval = "3600";
maxAge = builtins.toString (3600 * 24 * 30);
};
};
2023-09-18 12:13:09 +03:00
};
2023-09-18 12:38:17 +03:00
M-Documents = {
2024-08-05 18:48:52 +03:00
devices = [
"vno1-gdrx"
"fwminex"
];
2023-09-18 12:38:17 +03:00
id = "4fu7z-z6es2";
label = "M-Documents";
};
2024-03-23 19:45:11 +02:00
Vaikai = {
2024-07-29 15:39:54 +03:00
devices = [
"vno1-vinc"
"sqq1-desk"
2024-08-05 18:48:52 +03:00
"vno1-gdrx"
2024-07-29 15:39:54 +03:00
"fwminex"
"mtworx"
"v-kfire"
"mxp10"
"a-kfire"
];
2023-12-27 12:30:46 +02:00
id = "xbrfr-mhszm";
2024-03-23 19:45:11 +02:00
label = "Vaikai";
2023-10-24 22:07:51 +03:00
};
2023-09-18 12:38:17 +03:00
M-Camera = {
2024-07-29 15:39:54 +03:00
devices = [
"mxp10"
2024-08-05 18:48:52 +03:00
"vno1-gdrx"
2024-07-29 15:39:54 +03:00
"fwminex"
"mtworx"
];
2023-09-18 12:38:17 +03:00
id = "pixel_xl_dtm3-photos";
2024-01-25 09:05:46 +02:00
label = "M-Camera";
2023-09-18 12:38:17 +03:00
};
R-Documents = {
2024-08-03 16:55:08 +03:00
devices = [ "rzj-744P2PE" ];
2023-09-18 12:38:17 +03:00
id = "nm23h-aog6k";
label = "R-Documents";
};
Pictures = {
2024-08-05 18:48:52 +03:00
devices = [
"vno1-gdrx"
"fwminex"
];
2023-09-18 12:38:17 +03:00
id = "d3hur-cbzyw";
label = "Pictures";
};
2023-09-18 12:44:09 +03:00
Music = {
2024-07-29 15:39:54 +03:00
devices = [
2024-08-05 18:48:52 +03:00
"vno1-gdrx"
2024-07-29 15:39:54 +03:00
"fwminex"
"mtworx"
"mxp10"
];
2023-09-18 12:44:09 +03:00
id = "tg94v-cqcwr";
label = "music";
};
video-shared = {
2024-07-29 15:39:54 +03:00
devices = [
2024-08-05 18:48:52 +03:00
"vno1-gdrx"
2024-07-29 15:39:54 +03:00
"mxp10"
"mtworx"
"fwminex"
];
2023-09-18 12:44:09 +03:00
id = "byzmw-f6zhg";
label = "video-shared";
};
stud-cache = {
2024-08-05 18:48:52 +03:00
devices = [
"vno1-gdrx"
"fwminex"
];
2023-09-18 12:44:09 +03:00
id = "2kq7n-jqzxj";
label = "stud-cache";
};
M-R = {
2024-07-29 15:39:54 +03:00
devices = [
2024-08-05 18:48:52 +03:00
"vno1-gdrx"
2024-07-29 15:39:54 +03:00
"fwminex"
"rzj-744P2PE"
"mxp10"
"mtworx"
];
2023-09-18 12:44:09 +03:00
id = "evgn9-ahngz";
label = "M-R";
};
Irenos = {
2024-07-29 15:39:54 +03:00
devices = [
"sqq1-desk"
"vno2-irena"
];
2023-09-18 12:44:09 +03:00
id = "wuwai-qkcqj";
label = "Irenos";
};
2024-08-05 18:48:52 +03:00
www-vno1-gdrx = {
2024-08-05 21:53:39 +03:00
devices = [
"fwminex"
"vno1-gdrx"
];
2024-08-05 18:48:52 +03:00
id = "7z7ao-3hbxi";
label = "www-vno1-gdrx";
};
2024-07-29 19:55:34 +03:00
www-mtworx = {
2024-08-03 16:55:08 +03:00
devices = [ "mtworx" ];
2024-07-29 19:55:34 +03:00
id = "7z9sw-aaaa";
label = "www-mtworx";
};
2023-09-18 12:44:09 +03:00
www-mxp10 = {
2024-08-03 16:55:08 +03:00
devices = [ "mxp10" ];
2023-09-18 12:44:09 +03:00
id = "gqrtz-prx9h";
label = "www-mxp10";
};
mykolo = {
2024-07-29 15:39:54 +03:00
devices = [ "mxp10" ];
2023-09-18 12:44:09 +03:00
id = "wslmq-fyw4w";
label = "mykolo";
};
2023-09-18 12:13:09 +03:00
};
2024-07-29 15:39:54 +03:00
in
{
2023-07-26 11:36:54 +03:00
options.mj.services.syncthing = with lib.types; {
enable = lib.mkEnableOption "Enable services syncthing settings";
2024-07-29 15:39:54 +03:00
user = lib.mkOption { type = str; };
group = lib.mkOption { type = str; };
dataDir = lib.mkOption { type = path; };
2023-07-26 11:36:54 +03:00
};
2023-10-01 23:14:05 +03:00
config = lib.mkIf cfg.enable {
2023-09-12 15:46:44 +03:00
mj.services.friendlyport.ports = [
{
2023-09-12 16:08:08 +03:00
subnets = myData.subnets.motiejus.cidrs;
2024-07-29 15:39:54 +03:00
tcp = [ 8384 ];
2023-09-12 15:46:44 +03:00
}
];
2023-07-26 11:36:54 +03:00
2023-08-05 18:00:43 +03:00
services.syncthing = {
2024-07-29 15:39:54 +03:00
inherit (cfg)
enable
user
group
dataDir
;
2023-08-05 18:00:43 +03:00
openDefaultPorts = true;
2024-06-05 23:04:52 +03:00
key = config.age.secrets.syncthing-key.path;
cert = config.age.secrets.syncthing-cert.path;
2023-07-26 11:36:54 +03:00
2023-11-27 17:54:44 +02:00
settings = {
devices =
2024-07-29 15:39:54 +03:00
{ }
2024-08-05 18:48:52 +03:00
// (lib.optionalAttrs (config.networking.hostName == "vno1-gdrx") {
inherit (devices)
vno1-gdrx
fwminex
mtworx
mxp10
rzj-744P2PE
sqq1-desk
vno1-vinc
v-kfire
a-kfire
;
})
2024-08-03 16:55:08 +03:00
// (lib.optionalAttrs (config.networking.hostName == "fwminex") {
inherit (devices)
2024-08-05 18:48:52 +03:00
vno1-gdrx
2024-08-03 16:55:08 +03:00
fwminex
mtworx
mxp10
rzj-744P2PE
sqq1-desk
vno1-vinc
vno2-irena
v-kfire
a-kfire
;
})
2024-03-14 13:47:31 +02:00
// (lib.optionalAttrs (config.networking.hostName == "mtworx") {
2024-07-29 15:39:54 +03:00
inherit (devices)
2024-08-05 18:48:52 +03:00
vno1-gdrx
2024-03-14 13:47:31 +02:00
mtworx
2024-06-21 19:32:06 +03:00
fwminex
vno1-vinc
sqq1-desk
rzj-744P2PE
2024-03-14 13:47:31 +02:00
mxp10
2024-06-21 19:32:06 +03:00
a-kfire
v-kfire
2024-03-14 13:47:31 +02:00
;
})
2024-07-29 15:39:54 +03:00
// { };
folders =
with folders;
{ }
2024-08-03 16:55:08 +03:00
// (lib.optionalAttrs (config.networking.hostName == "fwminex") {
"/var/www/dl/tel" = www-mxp10;
2024-08-05 21:54:30 +03:00
"/var/www/dl/vno1-gdrx" = www-vno1-gdrx;
2024-08-03 16:55:08 +03:00
"/var/www/dl/mtworx" = www-mtworx;
"/var/www/dl/mykolo" = mykolo;
"${cfg.dataDir}/annex2/Books" = Books;
"${cfg.dataDir}/annex2/Mail" = Mail;
"${cfg.dataDir}/annex2/M-Active" = M-Active;
"${cfg.dataDir}/annex2/M-Camera" = M-Camera;
"${cfg.dataDir}/annex2/M-Documents" = M-Documents;
"${cfg.dataDir}/annex2/R-Documents" = R-Documents;
"${cfg.dataDir}/annex2/Pictures" = Pictures;
"${cfg.dataDir}/annex2/M-R" = M-R;
"${cfg.dataDir}/stud-cache" = stud-cache;
"${cfg.dataDir}/video/shared" = video-shared;
"${cfg.dataDir}/video/Vaikai" = Vaikai;
"${cfg.dataDir}/music" = Music;
"${cfg.dataDir}/irenos" = Irenos;
})
2024-07-29 15:39:54 +03:00
// (lib.optionalAttrs (config.networking.hostName == "mtworx") {
"${cfg.dataDir}/M-Active" = M-Active;
"${cfg.dataDir}/M-Camera" = M-Camera;
"${cfg.dataDir}/M-R" = M-R;
"${cfg.dataDir}/Vaikai" = Vaikai;
"${cfg.dataDir}/Video" = video-shared;
"${cfg.dataDir}/music" = Music;
2024-07-29 19:55:34 +03:00
"${cfg.dataDir}/www" = www-mtworx;
2024-08-05 18:48:52 +03:00
})
// (lib.optionalAttrs (config.networking.hostName == "vno1-gdrx") {
"${cfg.dataDir}/Books" = Books;
"${cfg.dataDir}/Mail" = Mail;
"${cfg.dataDir}/M-Active" = M-Active;
"${cfg.dataDir}/M-Camera" = M-Camera;
"${cfg.dataDir}/M-Documents" = M-Documents;
"${cfg.dataDir}/Pictures" = Pictures;
"${cfg.dataDir}/M-R" = M-R;
"${cfg.dataDir}/stud-cache" = stud-cache;
"${cfg.dataDir}/video/shared" = video-shared;
"${cfg.dataDir}/video/Vaikai" = Vaikai;
"${cfg.dataDir}/music" = Music;
"${cfg.dataDir}/www" = www-vno1-gdrx;
2024-07-29 15:39:54 +03:00
});
2023-11-27 17:54:44 +02:00
};
2023-07-26 11:36:54 +03:00
};
2023-08-05 18:00:43 +03:00
};
2023-07-26 11:36:54 +03:00
}