mirror of
https://github.com/SebastianStork/nixos-config.git
synced 2026-01-21 12:51:34 +01:00
syncthing: Connect devices over nebula instead of tailscale
This commit is contained in:
parent
bd196f1f27
commit
653ebd2c85
1 changed files with 49 additions and 36 deletions
|
|
@ -51,8 +51,8 @@ in
|
|||
config = lib.mkIf cfg.enable {
|
||||
assertions = [
|
||||
{
|
||||
assertion = config.custom.services.tailscale.enable;
|
||||
message = "Syncthing requires tailscale";
|
||||
assertion = config.custom.services.nebula.node.enable;
|
||||
message = "Syncthing requires nebula";
|
||||
}
|
||||
{
|
||||
assertion = cfg.isServer -> (cfg.gui.domain != null);
|
||||
|
|
@ -86,7 +86,8 @@ in
|
|||
};
|
||||
};
|
||||
|
||||
services.syncthing = {
|
||||
services = {
|
||||
syncthing = {
|
||||
enable = true;
|
||||
|
||||
user = lib.mkIf (!cfg.isServer) "seb";
|
||||
|
|
@ -105,9 +106,11 @@ in
|
|||
|> lib.filterAttrs (name: _: name != config.networking.hostName)
|
||||
|> lib.filterAttrs (_: value: value.config.custom.services.syncthing.enable)
|
||||
|> lib.mapAttrs (
|
||||
name: value: {
|
||||
_: value: {
|
||||
id = value.config.custom.services.syncthing.deviceId;
|
||||
addresses = [ "tcp://${name}.${config.custom.services.tailscale.domain}:${toString cfg.syncPort}" ];
|
||||
addresses = [
|
||||
"tcp://${value.config.custom.services.nebula.node.address}:${toString cfg.syncPort}"
|
||||
];
|
||||
}
|
||||
);
|
||||
|
||||
|
|
@ -119,7 +122,7 @@ in
|
|||
});
|
||||
|
||||
options = {
|
||||
listenAddress = "tcp://0.0.0.0:${toString cfg.syncPort}";
|
||||
listenAddress = "tcp://${config.custom.services.nebula.node.address}:${toString cfg.syncPort}";
|
||||
globalAnnounceEnabled = false;
|
||||
localAnnounceEnabled = false;
|
||||
relaysEnabled = false;
|
||||
|
|
@ -130,6 +133,16 @@ in
|
|||
};
|
||||
};
|
||||
|
||||
nebula.networks.mesh.firewall.inbound =
|
||||
config.services.syncthing.settings.devices
|
||||
|> lib.attrNames
|
||||
|> lib.map (name: {
|
||||
port = cfg.syncPort;
|
||||
proto = "tcp";
|
||||
host = name;
|
||||
});
|
||||
};
|
||||
|
||||
custom = {
|
||||
services = {
|
||||
caddy.virtualHosts.${cfg.gui.domain}.port = lib.mkIf (cfg.gui.domain != null) cfg.gui.port;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue