nixos-config/components/network/syncthing.nix

119 lines
3.5 KiB
Nix
Raw Normal View History

{ config, lib, pkgs, factsGenerator, clanLib, ... }:
2024-06-05 18:37:31 +02:00
let
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 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 16:55:55 +02:00
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-12 15:56:31 +02:00
// (device "iPhone" "RPQBSRB-DYEUUWQ-EAPMBA2-PL4MJ73-Y4F4ZTH-TAD7DUE-GEK56BG-HYW6YAF")
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";
2024-06-12 15:56:31 +02:00
devices = [ "chungus" "cream" "cherry" "iPhone" ];
2024-05-30 09:33:55 +02:00
};
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-06-10 15:11:48 +02:00
# to share big stuff public
share = {
enable = lib.mkDefault false;
path = lib.mkDefault "/tmp/password-store";
devices = [ "cream" "cherry" "orbi" ];
};
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
};
};
}