Get syncthing devices from the configs of the other hosts

This commit is contained in:
SebastianStork 2025-04-13 13:36:14 +02:00
parent 896549c6fb
commit 4bf2aef5cf
4 changed files with 30 additions and 17 deletions

View file

@ -47,6 +47,7 @@ in
syncthing = { syncthing = {
enable = true; enable = true;
isServer = true; isServer = true;
deviceId = "5R2MH7T-Q2ZZS2P-ZMSQ2UJ-B6VBHES-XYLNMZ6-7FYC27L-4P7MGJ2-FY4ITQD";
}; };
}; };
} }

View file

@ -24,6 +24,9 @@
enable = true; enable = true;
ssh.enable = true; ssh.enable = true;
}; };
syncthing.enable = true; syncthing = {
enable = true;
deviceId = "Q4YPD3V-GXZPHSN-PT5X4PU-FBG4GX2-IASBX75-7NYMG75-4EJHBMZ-4WGDDAP";
};
}; };
} }

View file

@ -21,7 +21,10 @@
enable = true; enable = true;
ssh.enable = true; ssh.enable = true;
}; };
syncthing.enable = true; syncthing = {
enable = true;
deviceId = "FAJS5WM-UAWGW2U-FXCGPSP-VAUOTGM-XUKSEES-D66PMCJ-WBODJLV-XTNCRA7";
};
steam.enable = true; steam.enable = true;
}; };

View file

@ -1,4 +1,9 @@
{ config, lib, ... }: {
config,
self,
lib,
...
}:
let let
cfg = config.myConfig.syncthing; cfg = config.myConfig.syncthing;
in in
@ -6,6 +11,10 @@ in
options.myConfig.syncthing = { options.myConfig.syncthing = {
enable = lib.mkEnableOption ""; enable = lib.mkEnableOption "";
isServer = lib.mkEnableOption ""; isServer = lib.mkEnableOption "";
deviceId = lib.mkOption {
type = lib.types.nonEmptyStr;
default = "";
};
}; };
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
@ -19,20 +28,17 @@ in
guiAddress = lib.mkIf cfg.isServer "0.0.0.0:8384"; guiAddress = lib.mkIf cfg.isServer "0.0.0.0:8384";
settings = { settings = {
devices = { # Get the devices and their ids from the configs of the other hosts
alto = { devices =
id = "5R2MH7T-Q2ZZS2P-ZMSQ2UJ-B6VBHES-XYLNMZ6-7FYC27L-4P7MGJ2-FY4ITQD"; self.nixosConfigurations
addresses = [ "tcp://alto.${config.networking.domain}:22000" ]; |> lib.filterAttrs (name: _: name != config.networking.hostName)
}; |> lib.filterAttrs (_: value: value.config.myConfig.syncthing.enable)
fern = { |> lib.mapAttrs (
id = "Q4YPD3V-GXZPHSN-PT5X4PU-FBG4GX2-IASBX75-7NYMG75-4EJHBMZ-4WGDDAP"; name: value: {
addresses = [ "tcp://fern.${config.networking.domain}:22000" ]; id = value.config.myConfig.syncthing.deviceId;
}; addresses = [ "tcp://${name}.${value.config.networking.domain}:22000" ];
north = { }
id = "FAJS5WM-UAWGW2U-FXCGPSP-VAUOTGM-XUKSEES-D66PMCJ-WBODJLV-XTNCRA7"; );
addresses = [ "tcp://north.${config.networking.domain}:22000" ];
};
};
folders = folders =
let let