2024-04-04 12:24:31 +02:00
|
|
|
{
|
|
|
|
config,
|
|
|
|
lib,
|
|
|
|
...
|
|
|
|
}: with lib; let
|
|
|
|
cfg = config.myOptions.services.syncthing;
|
|
|
|
username = config.myOptions.other.system.username;
|
|
|
|
hmCfg = config.home-manager.users.${username};
|
|
|
|
in {
|
|
|
|
options.myOptions.services.syncthing = {
|
|
|
|
enable = mkEnableOption "enable syncthing";
|
|
|
|
extraSettings = mkOption {
|
|
|
|
type = types.attrs;
|
|
|
|
description = "extra per host syncthing settings";
|
|
|
|
default = {};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
# https://wes.today/nixos-syncthing/
|
|
|
|
config = let
|
|
|
|
port = 8384;
|
|
|
|
homeDirectory = hmCfg.home.homeDirectory;
|
|
|
|
in mkIf cfg.enable {
|
|
|
|
services.syncthing = {
|
|
|
|
enable = true;
|
|
|
|
dataDir = homeDirectory;
|
|
|
|
configDir = "${hmCfg.xdg.configHome}/syncthing";
|
|
|
|
openDefaultPorts = true;
|
|
|
|
user = username;
|
|
|
|
group = "users";
|
|
|
|
guiAddress = "0.0.0.0:${toString port}";
|
|
|
|
overrideDevices = false;
|
|
|
|
overrideFolders = false;
|
2024-04-04 12:49:59 +02:00
|
|
|
settings = {
|
|
|
|
devices = {
|
2024-04-04 13:00:56 +02:00
|
|
|
niks.id = "2YJLRJI-PB3OKLI-KJZGMYQ-RH5OVCS-LQAXBUT-IX2Q5TO-K24NBNS-33YQIQL";
|
2024-04-04 12:51:18 +02:00
|
|
|
del.id = "NZUKCEW-QYCXDGY-62LOMIH-47JUSD5-VXAVUTF-VG356GJ-ZHQCF3S-2PDIHAX";
|
2024-04-04 12:49:59 +02:00
|
|
|
chmura.id = "TJCCHXS-HA5ZXUI-NKXWICR-4ADPHCA-TVRNDBN-54E622Z-TUAAVOM-YIJHWAI";
|
|
|
|
};
|
|
|
|
folders = {
|
|
|
|
Projects = {
|
|
|
|
path = "${homeDirectory}/Projects";
|
|
|
|
devices = [ "niks" "del" "chmura" ];
|
|
|
|
versioning = {
|
|
|
|
type = "staggered";
|
|
|
|
params = {
|
|
|
|
cleanInterval = "3600";
|
|
|
|
maxAge = "15552000";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
Studia = {
|
|
|
|
path = "${homeDirectory}/Studia";
|
|
|
|
devices = [ "niks" "del" "chmura" ];
|
|
|
|
versioning = {
|
|
|
|
type = "staggered";
|
|
|
|
params = {
|
|
|
|
cleanInterval = "3600";
|
|
|
|
maxAge = "15552000";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2024-04-04 12:54:17 +02:00
|
|
|
KeePassXC = {
|
|
|
|
path = "${homeDirectory}/KeePassXC";
|
2024-04-04 12:49:59 +02:00
|
|
|
devices = [ "niks" "del" "chmura" ];
|
|
|
|
versioning = {
|
|
|
|
type = "staggered";
|
|
|
|
params = {
|
|
|
|
cleanInterval = "3600";
|
|
|
|
maxAge = "15552000";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
Notes = {
|
|
|
|
path = "${homeDirectory}/Notes";
|
|
|
|
devices = [ "niks" "del" "chmura" ];
|
|
|
|
versioning = {
|
|
|
|
type = "staggered";
|
|
|
|
params = {
|
|
|
|
cleanInterval = "3600";
|
|
|
|
maxAge = "15552000";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
mieszkanie = {
|
|
|
|
path = "${homeDirectory}/mieszkanie";
|
|
|
|
devices = [ "niks" "del" "chmura" ];
|
|
|
|
versioning = {
|
|
|
|
type = "staggered";
|
|
|
|
params = {
|
|
|
|
cleanInterval = "3600";
|
|
|
|
maxAge = "15552000";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
} // cfg.extraSettings;
|
2024-04-04 12:24:31 +02:00
|
|
|
};
|
2024-04-04 12:41:54 +02:00
|
|
|
services.caddy = mkIf (username == "chmura") {
|
2024-04-04 12:24:31 +02:00
|
|
|
virtualHosts."sync.jacekpoz.pl".extraConfig = ''
|
|
|
|
reverse_proxy * localhost:${toString port}
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|