add syncthing

This commit is contained in:
Ingolf Wagner 2021-12-28 19:48:14 +01:00
parent 30721cfa83
commit ee9ff1306d
No known key found for this signature in database
GPG key ID: 76BF5F1928B9618B
6 changed files with 96 additions and 97 deletions

View file

@ -62,7 +62,7 @@
"secrets": { "secrets": {
"flake": false, "flake": false,
"locked": { "locked": {
"narHash": "sha256-9cKMk8P56Jy5X1Hk5gpisJAHZCAYuwiUNfs2diRWdws=", "narHash": "sha256-nl0nvXupyQ5mIdc9pVd0quWZwDJNcudUcbusp8Im+cM=",
"path": "/home/palo/dev/secrets", "path": "/home/palo/dev/secrets",
"type": "path" "type": "path"
}, },

View file

@ -10,9 +10,10 @@
./packages.nix ./packages.nix
./tinc.nix ./tinc.nix
./syncthing.nix
#./syncthing.nix
#../../system/server #../../system/server
#./hardware-configuration.nix #./hardware-configuration.nix
#./mail-fetcher.nix #./mail-fetcher.nix
#./transmission.nix #./transmission.nix
@ -48,6 +49,12 @@
fsType = "ext4"; fsType = "ext4";
}; };
fileSystems."/media" =
{
device = "/dev/vg/media";
fsType = "ext4";
};
} }

View file

@ -1,126 +1,111 @@
{ config, pkgs, lib, ... }: { { config, pkgs, lib, ... }: {
custom.samba-share = { imports = [ ../../system/all/syncthing.nix ];
enable = true;
folders = {
movies = config.services.syncthing.declarative.folders.movies.path;
series = config.services.syncthing.declarative.folders.series.path;
samples = config.services.syncthing.declarative.folders.samples.path;
music = config.services.syncthing.declarative.folders.music-library.path;
books = config.services.syncthing.declarative.folders.books.path;
};
};
sops.secrets.syncthing_cert = { }; sops.secrets.syncthing_cert = { };
sops.secrets.syncthing_key = { }; sops.secrets.syncthing_key = { };
networking.firewall.allowedTCPPorts = [ 22000 ];
networking.firewall.allowedUDPPorts = [ 22000 ];
services.syncthing = { services.syncthing = {
enable = true; enable = true;
openDefaultPorts = false; openDefaultPorts = false;
dataDir = "/home/syncthing"; dataDir = "/media/syncthing";
configDir = "/home/syncthing"; configDir = "/media/syncthing";
declarative = { declarative = {
overrideDevices = true;
overrideFolders = true;
cert = toString config.sops.secrets.syncthing_cert.path; cert = toString config.sops.secrets.syncthing_cert.path;
key = toString config.sops.secrets.syncthing_key.path; key = toString config.sops.secrets.syncthing_key.path;
overrideFolders = true;
folders = { folders = {
# on encrypted hard drive # on encrypted hard drive
# ----------------------- # -----------------------
private = { #private = {
enable = true; # enable = true;
path = "/home/syncthing/private"; # path = "/home/syncthing/private";
}; #};
desktop = { #desktop = {
enable = true; # enable = true;
path = "/home/syncthing/desktop"; # path = "/home/syncthing/desktop";
}; #};
finance = { #finance = {
enable = true; # enable = true;
path = "/home/syncthing/finance"; # path = "/home/syncthing/finance";
}; #};
fotos = { #fotos = {
enable = true; # enable = true;
path = "/home/syncthing/fotos"; # path = "/home/syncthing/fotos";
}; #};
lost-fotos = { #lost-fotos = {
enable = true; # enable = true;
path = "/home/syncthing/lost-fotos.ct"; # path = "/home/syncthing/lost-fotos.ct";
}; #};
zettlr = { #zettlr = {
enable = true; # enable = true;
path = "/home/syncthing/zettlr"; # path = "/home/syncthing/zettlr";
}; #};
# on media hard drive (not encrypted) # on media hard drive (not encrypted)
# ----------------------------------- # -----------------------------------
borg-mirror = { #borg-mirror = {
enable = true; # enable = true;
path = "/media/syncthing/borg"; # path = "/media/syncthing/borg";
rescanInterval = 36 * 3600; # rescanInterval = 36 * 3600;
type = "sendonly"; # type = "sendonly";
}; #};
video-material = { #video-material = {
enable = true; # enable = true;
path = "/home/syncthing/video-material"; # path = "/home/syncthing/video-material";
}; #};
music-library-free = { #music-library-free = {
enable = true; # enable = true;
path = "/media/syncthing/music-library-free"; # path = "/media/syncthing/music-library-free";
rescanInterval = 8 * 3600; # rescanInterval = 8 * 3600;
}; #};
books = { books = {
enable = true; enable = true;
path = "/media/syncthing/books"; path = "/media/syncthing/books";
rescanInterval = 8 * 3600;
}; };
samples = { samples = {
enable = true; enable = true;
path = "/media/syncthing/samples"; path = "/media/syncthing/samples";
rescanInterval = 8 * 3600;
}; };
movies = { movies = {
enable = true; enable = true;
path = "/media/syncthing/movies"; path = "/media/syncthing/movies";
rescanInterval = 8 * 3600;
};
# todo : no need to place it on encrypted drive
music-projects = {
enable = true;
path = "/home/syncthing/music-projects";
};
music-library = {
enable = true;
path = "/media/syncthing/music-library";
rescanInterval = 8 * 3600;
}; };
series = { series = {
enable = true; enable = true;
path = "/media/syncthing/series"; path = "/media/syncthing/series";
rescanInterval = 8 * 3600;
};
smartphone-folder = {
enable = true;
path = "/media/syncthing/smartphone-folder";
rescanInterval = 8 * 3600;
};
processing = {
enable = true;
path = "/media/syncthing/sketchbook";
rescanInterval = 8 * 3600;
}; };
# todo : no need to place it on encrypted drive
#music-projects = {
# enable = true;
# path = "/home/syncthing/music-projects";
#};
#music-library = {
# enable = true;
# path = "/media/syncthing/music-library";
# rescanInterval = 8 * 3600;
#};
#smartphone-folder = {
# enable = true;
# path = "/media/syncthing/smartphone-folder";
# rescanInterval = 8 * 3600;
#};
#processing = {
# enable = true;
# path = "/media/syncthing/sketchbook";
# rescanInterval = 8 * 3600;
#};
}; };
}; };
}; };
system.permown."/home/syncthing" = {
owner = "syncthing";
group = "syncthing";
umask = "0022";
};
system.permown."/media/syncthing" = { system.permown."/media/syncthing" = {
owner = "syncthing"; owner = "syncthing";
group = "syncthing"; group = "syncthing";
@ -135,6 +120,6 @@
after = [ "media.mount" ]; after = [ "media.mount" ];
}; };
backup.dirs = [ "/home/syncthing/finance" ]; #backup.dirs = [ "/home/syncthing/finance" ];
} }

View file

@ -13,7 +13,7 @@
./gogs.nix ./gogs.nix
./grafana.nix ./grafana.nix
./graylog.nix ./graylog.nix
./jenkins.nix #./jenkins.nix
#./kibana.nix #./kibana.nix
./mysql.nix ./mysql.nix
./packages.nix ./packages.nix

View file

@ -4,7 +4,7 @@ with lib; {
services.syncthing = { services.syncthing = {
guiAddress = lib.mkDefault "${config.networking.hostName}.private:8384"; guiAddress = lib.mkDefault "${config.networking.hostName}.private:8384";
declarative = { declarative = {
overrideDevices = true; overrideDevices = lib.mkDefault true;
devices = devices =
let let
device = name: id: { device = name: id: {
@ -12,22 +12,29 @@ with lib; {
name = name; name = name;
id = id; id = id;
addresses = addresses =
[ "tcp://${name}.private:22000" "tcp://${name}.private:21027" ]; [ "tcp://${name}.private:22000" ];
}; };
}; };
in in
(device "workhorse" {
"robi" = {
name = "robi";
id = "B6P22RF-5BC2LTZ-6GHVWRZ-5D3OLXC-D66E45Y-JEB3WYT-ZQ442WZ-5FFAMQ7";
addresses = [ "tcp://144.76.13.147:22000" ];
};
}
// (device "workhorse"
"AFSAKB6-JLH4QAS-DSRMPI3-6PVCIHF-IIAVLPC-STPNO3Y-YRDU5NW-QD445QI") "AFSAKB6-JLH4QAS-DSRMPI3-6PVCIHF-IIAVLPC-STPNO3Y-YRDU5NW-QD445QI")
// (device "pepe" // (device "pepe"
"SZLXFW3-VTAC7UB-V2Z7CHE-3VZAYPL-6D72AK6-OCDMPZP-G4FPY5P-FL6ZVAG") "SZLXFW3-VTAC7UB-V2Z7CHE-3VZAYPL-6D72AK6-OCDMPZP-G4FPY5P-FL6ZVAG")
// (device "workout" // (device "workout"
"DZOOAKG-GI2SVOS-QEVMFL7-TRHVTPQ-ADIJEVH-RH5WV3J-6M7MJHC-C53EOAC") "DZOOAKG-GI2SVOS-QEVMFL7-TRHVTPQ-ADIJEVH-RH5WV3J-6M7MJHC-C53EOAC")
// (device "sterni" // (device "sterni"
"ZFNNKPD-ZSOAYJQ-VROXXDB-5MD3UTJ-GDCNTSQ-G5POVV3-UZG5HFT-CCAU3AD") // { "ZFNNKPD-ZSOAYJQ-VROXXDB-5MD3UTJ-GDCNTSQ-G5POVV3-UZG5HFT-CCAU3AD")
// {
"porani" = { "porani" = {
name = "porani"; name = "porani";
id = id = "6YOIA4E-X52ZD5Z-FPNWPRS-77QIMMU-VDIXVZB-6BPQN7A-FFJDU4W-EXEGFAI";
"6YOIA4E-X52ZD5Z-FPNWPRS-77QIMMU-VDIXVZB-6BPQN7A-FFJDU4W-EXEGFAI";
addresses = addresses =
[ "tcp://porani.secret:22000" "tcp://porani.secret:21027" ]; [ "tcp://porani.secret:22000" "tcp://porani.secret:21027" ];
}; };
@ -120,7 +127,7 @@ with lib; {
enable = lib.mkDefault false; enable = lib.mkDefault false;
id = "wwbvs-5lfbh"; id = "wwbvs-5lfbh";
watch = false; watch = false;
devices = [ "workhorse" "pepe" "sterni" ]; devices = [ "workhorse" "pepe" "sterni" "robi" ];
versioning = { versioning = {
type = "simple"; type = "simple";
params.keep = "10"; params.keep = "10";
@ -139,7 +146,7 @@ with lib; {
enable = lib.mkDefault false; enable = lib.mkDefault false;
id = "vatmy-c2qf4"; id = "vatmy-c2qf4";
watch = false; watch = false;
devices = [ "workhorse" "pepe" "porani" ]; devices = [ "workhorse" "pepe" "porani" "robi" ];
versioning = { versioning = {
type = "simple"; type = "simple";
params.keep = "3"; params.keep = "3";
@ -189,13 +196,13 @@ with lib; {
enable = lib.mkDefault false; enable = lib.mkDefault false;
id = "pcgkj-tjucd"; id = "pcgkj-tjucd";
watch = false; watch = false;
devices = [ "workout" "workhorse" "sterni" "pepe" ]; devices = [ "workhorse" "sterni" "pepe" "robi" ];
}; };
series = { series = {
enable = lib.mkDefault false; enable = lib.mkDefault false;
id = "all-series"; id = "all-series";
watch = false; watch = false;
devices = [ "workhorse" "porani" "pepe" ]; devices = [ "workhorse" "porani" "pepe" "robi" ];
versioning = { versioning = {
type = "simple"; type = "simple";
params.keep = "10"; params.keep = "10";

View file

@ -114,7 +114,7 @@ in
publicKey = lib.fileContents ../../assets/tinc/workhorse_host_file; publicKey = lib.fileContents ../../assets/tinc/workhorse_host_file;
}; };
robi = { robi = {
realAddress = ["144.76.13.147"]; realAddress = [ "144.76.13.147" ];
tincIp = "10.23.42.111"; tincIp = "10.23.42.111";
publicKey = lib.fileContents ../../assets/tinc/robi_host_file; publicKey = lib.fileContents ../../assets/tinc/robi_host_file;
}; };