mirror of
https://github.com/SebastianStork/nixos-config.git
synced 2026-01-21 19: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 {
|
config = lib.mkIf cfg.enable {
|
||||||
assertions = [
|
assertions = [
|
||||||
{
|
{
|
||||||
assertion = config.custom.services.tailscale.enable;
|
assertion = config.custom.services.nebula.node.enable;
|
||||||
message = "Syncthing requires tailscale";
|
message = "Syncthing requires nebula";
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
assertion = cfg.isServer -> (cfg.gui.domain != null);
|
assertion = cfg.isServer -> (cfg.gui.domain != null);
|
||||||
|
|
@ -86,48 +86,61 @@ in
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
services.syncthing = {
|
services = {
|
||||||
enable = true;
|
syncthing = {
|
||||||
|
enable = true;
|
||||||
|
|
||||||
user = lib.mkIf (!cfg.isServer) "seb";
|
user = lib.mkIf (!cfg.isServer) "seb";
|
||||||
group = lib.mkIf (!cfg.isServer) "users";
|
group = lib.mkIf (!cfg.isServer) "users";
|
||||||
dataDir = lib.mkIf (!cfg.isServer) "/home/seb";
|
dataDir = lib.mkIf (!cfg.isServer) "/home/seb";
|
||||||
|
|
||||||
guiAddress = "localhost:${toString cfg.gui.port}";
|
guiAddress = "localhost:${toString cfg.gui.port}";
|
||||||
|
|
||||||
cert = lib.mkIf useSopsSecrets config.sops.secrets."syncthing/cert".path;
|
cert = lib.mkIf useSopsSecrets config.sops.secrets."syncthing/cert".path;
|
||||||
key = lib.mkIf useSopsSecrets config.sops.secrets."syncthing/key".path;
|
key = lib.mkIf useSopsSecrets config.sops.secrets."syncthing/key".path;
|
||||||
|
|
||||||
settings = {
|
settings = {
|
||||||
# Get the devices and their ids from the configs of the other hosts
|
# Get the devices and their ids from the configs of the other hosts
|
||||||
devices =
|
devices =
|
||||||
self.nixosConfigurations
|
self.nixosConfigurations
|
||||||
|> lib.filterAttrs (name: _: name != config.networking.hostName)
|
|> lib.filterAttrs (name: _: name != config.networking.hostName)
|
||||||
|> lib.filterAttrs (_: value: value.config.custom.services.syncthing.enable)
|
|> lib.filterAttrs (_: value: value.config.custom.services.syncthing.enable)
|
||||||
|> lib.mapAttrs (
|
|> lib.mapAttrs (
|
||||||
name: value: {
|
_: value: {
|
||||||
id = value.config.custom.services.syncthing.deviceId;
|
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}"
|
||||||
);
|
];
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
folders =
|
folders =
|
||||||
cfg.folders
|
cfg.folders
|
||||||
|> lib'.genAttrs (name: {
|
|> lib'.genAttrs (name: {
|
||||||
path = "${dataDir}/${name}";
|
path = "${dataDir}/${name}";
|
||||||
devices = config.services.syncthing.settings.devices |> lib.attrNames;
|
devices = config.services.syncthing.settings.devices |> lib.attrNames;
|
||||||
});
|
});
|
||||||
|
|
||||||
options = {
|
options = {
|
||||||
listenAddress = "tcp://0.0.0.0:${toString cfg.syncPort}";
|
listenAddress = "tcp://${config.custom.services.nebula.node.address}:${toString cfg.syncPort}";
|
||||||
globalAnnounceEnabled = false;
|
globalAnnounceEnabled = false;
|
||||||
localAnnounceEnabled = false;
|
localAnnounceEnabled = false;
|
||||||
relaysEnabled = false;
|
relaysEnabled = false;
|
||||||
natEnabled = false;
|
natEnabled = false;
|
||||||
urAccepted = -1;
|
urAccepted = -1;
|
||||||
autoUpgradeIntervalH = 0;
|
autoUpgradeIntervalH = 0;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
nebula.networks.mesh.firewall.inbound =
|
||||||
|
config.services.syncthing.settings.devices
|
||||||
|
|> lib.attrNames
|
||||||
|
|> lib.map (name: {
|
||||||
|
port = cfg.syncPort;
|
||||||
|
proto = "tcp";
|
||||||
|
host = name;
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
custom = {
|
custom = {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue