syncthing: Add phone in a hacky way

This commit is contained in:
SebastianStork 2026-02-07 20:35:54 +01:00
parent ed070e6abe
commit fa2bef14f4
Signed by: SebastianStork
SSH key fingerprint: SHA256:tRrGdjYOwgHxpSc/wTOZQZEjxcb15P0tyXRsbAfd+2Q
2 changed files with 39 additions and 28 deletions

View file

@ -85,17 +85,20 @@ in
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 =
devices = let
hosts =
self.nixosConfigurations self.nixosConfigurations
|> lib.filterAttrs (_: host: host.config.networking.hostName != config.networking.hostName) |> lib.filterAttrs (_: host: host.config.networking.hostName != config.networking.hostName)
|> lib.filterAttrs (_: host: host.config.custom.services.syncthing.enable) |> lib.filterAttrs (_: host: host.config.custom.services.syncthing.enable);
in
{
devices =
hosts
|> lib.mapAttrs ( |> lib.mapAttrs (
_: host: { _: host: {
id = host.config.custom.services.syncthing.deviceId; id = host.config.custom.services.syncthing.deviceId;
addresses = [ addresses = lib.singleton "tcp://${host.config.custom.networking.overlay.address}:${toString host.config.custom.services.syncthing.syncPort}";
"tcp://${host.config.custom.networking.overlay.address}:${toString host.config.custom.services.syncthing.syncPort}"
];
} }
); );
@ -103,7 +106,7 @@ in
cfg.folders cfg.folders
|> self.lib.genAttrs (name: { |> self.lib.genAttrs (name: {
path = "${dataDir}/${name}"; path = "${dataDir}/${name}";
devices = config.services.syncthing.settings.devices |> lib.attrNames; devices = hosts |> lib.attrNames;
}); });
options = { options = {

View file

@ -112,4 +112,12 @@
sshd.enable = true; sshd.enable = true;
}; };
}; };
services.syncthing.settings = {
devices."fairphone" = {
id = "6ROH65D-E65I5F6-URI4OUZ-RCHFC3B-PMBSIHH-5DNLJPS-SYSUWQY-HKYGHQG";
addresses = "tcp://10.254.250.74:22000";
};
folders."Documents".devices = [ config.services.syncthing.settings.devices."fairphone".name ];
};
} }