infra/nix/os/containers/syncthing.nix

64 lines
1.2 KiB
Nix
Raw Normal View History

2023-03-21 13:38:22 +01:00
{
2024-06-01 21:46:09 +02:00
specialArgs,
2023-03-21 13:38:22 +01:00
hostAddress,
localAddress,
syncthingPort ? 22000,
syncthingLocalAnnouncePort ? 21027,
autoStart ? false,
2023-02-07 18:24:28 +01:00
}: {
2024-06-01 21:46:09 +02:00
inherit specialArgs;
2023-03-21 13:38:22 +01:00
config = {
config,
pkgs,
...
}: {
system.stateVersion = "20.05"; # Did you read the comment?
imports = [../profiles/containers/configuration.nix];
networking.firewall.enable = true;
networking.firewall.allowedTCPPorts = [
# syncthing gui
8384
];
services.syncthing = {
enable = true;
openDefaultPorts = true;
guiAddress = "0.0.0.0:8384";
};
2023-03-21 13:38:22 +01:00
};
inherit autoStart;
bindMounts = {
"/var/lib/syncthing/" = {
hostPath = "/var/lib/container-volumes/syncthing/var-lib-syncthing";
isReadOnly = false;
};
};
2023-03-21 13:38:22 +01:00
extraFlags = ["--resolv-conf=bind-host"];
privateNetwork = true;
forwardPorts = [
{
containerPort = 22000;
hostPort = syncthingPort;
protocol = "tcp";
}
{
containerPort = 22000;
hostPort = syncthingPort;
protocol = "udp";
}
{
containerPort = 21027;
hostPort = syncthingLocalAnnouncePort;
protocol = "udp";
}
];
inherit hostAddress localAddress;
}