From ffc34eb99c36c11fe3482b81bdf6d2bb954773c2 Mon Sep 17 00:00:00 2001 From: Daniel Langbein Date: Tue, 28 Nov 2023 15:21:03 +0100 Subject: [PATCH] syncthing server --- hosts/yodaNas/configuration.nix | 2 ++ hosts/yodaNas/host-specific.nix | 4 +++- hosts/yodaNas/syncthing.nix | 34 +++++++++++++++++++++++++++++++++ 3 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 hosts/yodaNas/syncthing.nix diff --git a/hosts/yodaNas/configuration.nix b/hosts/yodaNas/configuration.nix index daabc72..ebf25a3 100644 --- a/hosts/yodaNas/configuration.nix +++ b/hosts/yodaNas/configuration.nix @@ -24,6 +24,7 @@ ../../modules/btrbk ./btrbk-config.nix + ../../modules/netcup-dns.nix ../../modules/de-p1st-monitor.nix ../../modules/spin-down/hdparm.nix @@ -46,6 +47,7 @@ "ata-WDC_WD30EFRX-68EUZN0_WD-WMC4N0564095" ]; yoda.spin-down.hd-idle = []; + yoda.de-p1st-monitor = (builtins.readFile ../../assets/de-p1st-monitor/yodaNas.ini); boot.kernelParams = [ # Microarchitectural Data Sampling (MDS), see https://www.kernel.org/doc/html/latest/admin-guide/hw-vuln/mds.html#mitigation-control-on-the-kernel-command-line diff --git a/hosts/yodaNas/host-specific.nix b/hosts/yodaNas/host-specific.nix index 0325407..9edcca0 100644 --- a/hosts/yodaNas/host-specific.nix +++ b/hosts/yodaNas/host-specific.nix @@ -1,6 +1,8 @@ { config, pkgs, ... }: { - yoda.de-p1st-monitor = (builtins.readFile ../../assets/de-p1st-monitor/yodaNas.ini); + imports = [ + ./syncthing.nix + ]; # Update and start Jinja-Compose project # during boot and after every 30 minutes. diff --git a/hosts/yodaNas/syncthing.nix b/hosts/yodaNas/syncthing.nix new file mode 100644 index 0000000..4db9f38 --- /dev/null +++ b/hosts/yodaNas/syncthing.nix @@ -0,0 +1,34 @@ +# https://nixos.wiki/wiki/Syncthing + +# Manually create syncthing.folders..path and chown it to user/group `syncthing` +# before starting the Syncthing service. + +# You can get your device id with: +# sudo cat /var/lib/syncthing/.config/syncthing/config.xml | grep 'device id="' + +{ config, pkgs, ... }: +{ + services = { + syncthing = { + enable = true; + # Whether to open the default ports in the firewall: TCP/UDP 22000 for transfers and UDP 21027 for discovery. + openDefaultPorts = true; + overrideDevices = true; # overrides any devices added or deleted through the WebUI + overrideFolders = true; # overrides any folders added or deleted through the WebUI + devices = { + "yodaTux" = { id = "AKAIZ66-G67WC4J-WEYBOGF-TNXWBT3-BCSETRQ-2BEHCT7-GSZQRWP-IGXKSQK"; }; + "yodaEnchilada" = { id = "BZOGQNN-KGSFOTI-5QZ7I7U-4XW5KD6-ITKMWB6-6L6QX6X-JSMAGFQ-7BOEUA5"; }; + "yodaCheeseburger" = { id = "KHR22KP-WK6EL25-Z3DPLZK-5IHU7BC-QYXFQJA-U7JE2JA-ITYNV3Q-JE5VKAJ"; }; + }; + folders = { + # Name of folder in Syncthing, also the folder ID. + "Notes" = { + # Path to shared folder. + path = "/mnt/data/syncthing/notes"; + # Which devices to share the folder with. + devices = [ "yodaTux" "yodaEnchilada" "yodaCheeseburger" ]; + }; + }; + }; + }; +}