nixos-config/components/network/syncthing.nix

136 lines
4.1 KiB
Nix
Raw Normal View History

{ config, lib, pkgs, factsGenerator, clanLib, ... }:
2024-06-05 18:37:31 +02:00
let
syncthingPub = clanLib.readFact "syncthing.pub";
zerotierIp = clanLib.readFact "zerotier-ip";
2024-06-07 07:54:43 +02:00
clanMachines =
lib.mapAttrs
(machine: facts: {
name = machine;
id = facts."syncthing.pub";
addresses = [ "tcp://[${facts."zerotier-ip"}]:22000" ];
})
(clanLib.readFactsFromAllMachines [ "syncthing.pub" "zerotier-ip" ]);
2024-06-05 18:37:31 +02:00
in
2019-12-20 05:54:26 +01:00
with lib; {
2019-10-24 02:20:38 +02:00
2024-06-05 18:37:31 +02:00
# networking.firewall.interfaces."gummybears".allowedTCPPorts = [ 8384 ];
2024-06-02 20:50:17 +02:00
clanCore.facts.services.syncthing = factsGenerator.syncthing { };
2024-06-04 09:13:35 +02:00
2020-11-21 18:56:11 +01:00
services.syncthing = {
2024-06-05 18:37:31 +02:00
#guiAddress = lib.mkDefault "${config.networking.hostName}.${config.clan.static-hosts.topLevelDomain}:8384";
#guiAddress = lib.mkDefault "[${zerotierIp config.networking.hostName}]:8384";
2024-06-05 16:55:55 +02:00
guiAddress = lib.mkDefault "${config.networking.hostName}.private:8384";
2022-01-09 19:22:12 +01:00
overrideDevices = lib.mkDefault true;
2024-06-05 17:26:42 +02:00
key = config.clanCore.facts.services.syncthing.secret."syncthing.key".path;
cert = config.clanCore.facts.services.syncthing.secret."syncthing.cert".path;
2023-12-08 22:47:37 +01:00
settings.devices =
2022-01-09 19:22:12 +01:00
let
2024-06-05 18:37:31 +02:00
zeroDevice = machine: {
2024-06-02 20:50:17 +02:00
"${machine}" = {
name = machine;
id = syncthingPub machine;
addresses = [ "tcp://[${zerotierIp machine}]:22000" ];
};
};
2024-06-05 16:55:55 +02:00
tincDevice = machine: {
"${machine}" = {
name = machine;
id = syncthingPub machine;
addresses = [ "tcp://${machine}.private:22000" ];
};
};
device = machine: id: {
"${machine}" = {
name = machine;
2022-01-09 19:22:12 +01:00
id = id;
2024-06-05 16:55:55 +02:00
#addresses = [ "tcp://${machine}.private:22000" ];
2022-01-09 19:22:12 +01:00
};
};
in
2024-06-07 07:54:43 +02:00
clanMachines
2024-06-02 20:50:17 +02:00
#// (device "mobi" )
#// (device "bobi" )
2024-04-24 17:28:41 +02:00
// (device "iPhone" "APFS6SA-VVTARXU-3WHHRZG-TE5N3T4-X4IC76V-T67EKZ6-NLGP3TW-EZYXYAH")
// (device "iPad" "JDDNVYD-H3WMSSS-WZ745KL-7QEGN6O-ZSGQLQU-YBR2L42-7FO7KJ4-BXPYDA5")
2024-06-05 16:55:55 +02:00
// (device "bumba" "JS7PWTO-VKFGBUP-GNFLSWP-MGFJ2KH-HLO2LKW-V3RPCR6-PCB5SQC-42FCKQZ")
;
2019-10-24 02:20:38 +02:00
2023-12-08 22:47:37 +01:00
settings.folders = {
2019-10-25 03:03:25 +02:00
2022-01-09 19:22:12 +01:00
# needs to be on encrypted drives
# -------------------------------
2024-04-17 10:00:17 +02:00
audiobooks = {
enable = lib.mkDefault false;
path = lib.mkDefault "/tmp/audiobooks";
devices = [ "chungus" "orbi" ];
};
2023-05-12 11:17:58 +02:00
books = {
enable = lib.mkDefault false;
2023-12-08 21:27:52 +01:00
path = lib.mkDefault "/tmp/books";
2024-06-02 20:50:17 +02:00
devices = [ "chungus" "cream" "cherry" ];
2022-12-15 15:48:53 +01:00
versioning = {
type = "simple";
params.keep = "2";
};
};
2022-01-09 19:22:12 +01:00
desktop = {
enable = lib.mkDefault false;
2023-12-08 21:27:52 +01:00
path = lib.mkDefault "/tmp/desktop";
2024-06-02 20:50:17 +02:00
devices = [ "chungus" "cream" "cherry" ];
2022-01-09 19:22:12 +01:00
};
finance = {
enable = lib.mkDefault false;
2023-12-08 21:27:52 +01:00
path = lib.mkDefault "/tmp/finance";
2024-06-02 20:50:17 +02:00
devices = [ "chungus" "cream" "cherry" ];
2022-01-09 19:22:12 +01:00
versioning = {
type = "simple";
params.keep = "10";
2019-10-24 02:20:38 +02:00
};
2022-01-09 19:22:12 +01:00
};
2024-05-30 09:33:55 +02:00
flix = {
2022-01-09 19:22:12 +01:00
enable = lib.mkDefault false;
2024-05-30 09:33:55 +02:00
path = lib.mkDefault "/tmp/flix";
devices = [ "chungus" "orbi" ];
};
logseq = {
enable = lib.mkDefault false;
path = lib.mkDefault "/tmp/logseq";
devices = [ "chungus" "cream" "cherry" "iPhone" "iPad" ];
};
lectures = {
enable = lib.mkDefault false;
path = lib.mkDefault "/tmp/lectures";
devices = [ "chungus" "orbi" ];
};
oscar_cpap = {
enable = lib.mkDefault false;
path = lib.mkDefault "/tmp/oscar_cpap";
devices = [ "chungus" "cream" "cherry" ];
};
password-store = {
enable = lib.mkDefault false;
path = lib.mkDefault "/tmp/password-store";
2024-06-02 20:50:17 +02:00
devices = [ "chungus" "cream" "cherry" ];
2022-01-09 19:22:12 +01:00
versioning = {
type = "simple";
2024-05-30 09:33:55 +02:00
params.keep = "10";
2019-10-24 02:20:38 +02:00
};
2022-01-09 19:22:12 +01:00
};
2024-05-30 09:33:55 +02:00
# todo remove if zfs is is used
#nextcloud_backup = {
# enable = lib.mkDefault false;
# path = lib.mkDefault "/tmp/lost-fotos";
2024-06-02 20:50:17 +02:00
# devices = [ "chungus" ];
2024-05-30 09:33:55 +02:00
# versioning = {
# type = "simple";
# params.keep = "2";
# };
#};
2019-10-24 02:20:38 +02:00
};
};
}