2024-10-22 21:11:00 -07:00
|
|
|
{ config, lib, pkgs, user, ... }:
|
|
|
|
|
2024-10-23 22:39:10 -07:00
|
|
|
let cfg = config.modules.programs.syncthing;
|
2024-10-22 21:11:00 -07:00
|
|
|
in {
|
2024-10-23 22:39:10 -07:00
|
|
|
options.modules.programs.syncthing = with lib; {
|
2024-10-22 21:11:00 -07:00
|
|
|
enable = lib.mkOption {
|
|
|
|
type = types.bool;
|
2024-10-23 08:53:27 -07:00
|
|
|
default = false;
|
2024-10-22 21:11:00 -07:00
|
|
|
};
|
|
|
|
keyPath = mkOption {
|
|
|
|
type = types.path;
|
|
|
|
default = ./key.pem;
|
|
|
|
};
|
|
|
|
certPath = mkOption {
|
|
|
|
type = types.path;
|
|
|
|
default = ./cert.pem;
|
|
|
|
};
|
|
|
|
devices = mkOption {
|
|
|
|
type = types.attrs;
|
|
|
|
default = {};
|
|
|
|
description = ''
|
|
|
|
A set of devices and associated IDs.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = lib.mkIf cfg.enable {
|
|
|
|
environment.systemPackages = with pkgs; [
|
|
|
|
syncthing # File sync program for multiple devices in real-time.
|
|
|
|
];
|
|
|
|
|
|
|
|
networking.firewall.allowedTCPPorts = [ 8384 22000 ];
|
|
|
|
networking.firewall.allowedUDPPorts = [ 22000 21027 ];
|
|
|
|
|
|
|
|
age.secrets."syncthing/key.pem" = {
|
|
|
|
file = cfg.keyPath;
|
|
|
|
owner = "${user}";
|
|
|
|
group = "users";
|
|
|
|
};
|
|
|
|
age.secrets."syncthing/cert.pem" = {
|
|
|
|
file = cfg.certPath;
|
|
|
|
owner = "${user}";
|
|
|
|
group = "users";
|
|
|
|
};
|
|
|
|
|
|
|
|
services.syncthing = {
|
|
|
|
enable = true;
|
|
|
|
user = "${user}";
|
|
|
|
dataDir = "/home/${user}/.local/share/syncthing";
|
|
|
|
configDir = "/home/${user}/.config/syncthing";
|
|
|
|
guiAddress = "0.0.0.0:8384";
|
|
|
|
key = "/run/agenix/syncthing/key.pem";
|
|
|
|
cert = "/run/agenix/syncthing/cert.pem";
|
2024-10-23 22:39:10 -07:00
|
|
|
overrideFolders = false; # don't delete user add folders
|
2024-10-22 21:11:00 -07:00
|
|
|
settings.devices = cfg.devices;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|