From c6e50d9232d1ea3036571cc4af7a6d2824287767 Mon Sep 17 00:00:00 2001 From: Swarsel Date: Thu, 17 Oct 2024 00:09:24 +0200 Subject: [PATCH] feat: add syncthing on winters --- SwarselSystems.org | 93 ++++++++++++++++++++++++++-- modules/nixos/setup.nix | 1 + profiles/common/nixos/syncthing.nix | 11 ++-- profiles/server/common/default.nix | 1 + profiles/server/common/syncthing.nix | 74 ++++++++++++++++++++++ profiles/server/winters/default.nix | 1 + 6 files changed, 173 insertions(+), 8 deletions(-) create mode 100644 profiles/server/common/syncthing.nix diff --git a/SwarselSystems.org b/SwarselSystems.org index 0f0e8cf..374f331 100644 --- a/SwarselSystems.org +++ b/SwarselSystems.org @@ -2064,6 +2064,7 @@ My work machine. Built for more security, this is the gold standard of my config immich = true; paperless = true; transmission = true; + syncthing = true; }; }; @@ -4752,6 +4753,7 @@ I usually use =mutableUsers = false= in my NixOS configuration. However, on a ne options.swarselsystems.server.immich = lib.mkEnableOption "enable immich on server"; options.swarselsystems.server.paperless = lib.mkEnableOption "enable paperless on server"; options.swarselsystems.server.transmission = lib.mkEnableOption "enable transmission and friends on server"; + options.swarselsystems.server.syncthing = lib.mkEnableOption "enable syncthing on server"; } #+end_src @@ -5990,6 +5992,9 @@ Do not touch this. settings = { devices = { "magicant" = { + id = "VMWGEE2-4HDS2QO-KNQOVGN-LXLX6LA-666E4EK-ZBRYRRO-XFEX6FB-6E3XLQO"; + }; + "zenfone9" = { id = "SEH2NMT-IVRQUU5-VPW2HUQ-3GQYDBF-F6H6OY6-X3DZTUZ-LCRE2DJ-QNIXIQ2"; }; "sync (@oracle)" = { @@ -6002,22 +6007,22 @@ Do not touch this. folders = { "Default Folder" = { path = "/home/swarsel/Sync"; - devices = [ "sync (@oracle)" "magicant" ]; + devices = [ "sync (@oracle)" "magicant" "zenfone9" ]; id = "default"; }; "Obsidian" = { path = "/home/swarsel/Nextcloud/Obsidian"; - devices = [ "sync (@oracle)" "magicant" ]; + devices = [ "sync (@oracle)" "magicant" "zenfone9" ]; id = "yjvni-9eaa7"; }; "Org" = { path = "/home/swarsel/Nextcloud/Org"; - devices = [ "sync (@oracle)" "magicant" ]; + devices = [ "sync (@oracle)" "magicant" "zenfone9" ]; id = "a7xnl-zjj3d"; }; "Vpn" = { path = "/home/swarsel/Vpn"; - devices = [ "sync (@oracle)" "magicant" ]; + devices = [ "sync (@oracle)" "magicant" "zenfone9" ]; id = "hgp9s-fyq3p"; }; }; @@ -6676,6 +6681,7 @@ Also, the system state version is set here. No need to touch it. ./immich.nix ./paperless.nix ./transmission.nix + ./syncthing.nix ]; nix = @@ -7656,6 +7662,85 @@ Also, the system state version is set here. No need to touch it. #+end_src +**** syncthing + +#+begin_src nix :tangle profiles/server/common/syncthing.nix + { pkgs, lib, config, ... }: + { + config = lib.mkIf config.swarselsystems.server.syncthing { + + users.users.syncthing = { + extraGroups = [ "users" ]; + }; + + services.syncthing = { + enable = true; + user = "syncthing"; + dataDir = "/Vault/data/syncthing"; + configDir = "/Vault/apps/syncthing"; + guiAddress = "0.0.0.0:8384"; + openDefaultPorts = true; + settings = { + devices = { + "magicant" = { + id = "VMWGEE2-4HDS2QO-KNQOVGN-LXLX6LA-666E4EK-ZBRYRRO-XFEX6FB-6E3XLQO"; + }; + "zenfone9" = { + id = "SEH2NMT-IVRQUU5-VPW2HUQ-3GQYDBF-F6H6OY6-X3DZTUZ-LCRE2DJ-QNIXIQ2"; + }; + "sync (@oracle)" = { + id = "ETW6TST-NPK7MKZ-M4LXMHA-QUPQHDT-VTSHH5X-CR5EIN2-YU7E55F-MGT7DQB"; + }; + "nbl-imba-2" = { + id = "YAPV4BV-I26WPTN-SIP32MV-SQP5TBZ-3CHMTCI-Z3D6EP2-MNDQGLP-53FT3AB"; + }; + }; + folders = { + "Default Folder" = { + path = "/Vault/data/syncthing/Sync"; + devices = [ "sync (@oracle)" "magicant" "zenfone9" "nbl-imba-2" ]; + id = "default"; + }; + "Obsidian" = { + path = "/Vault/data/syncthing/Obsidian"; + devices = [ "sync (@oracle)" "magicant" "zenfone9" "nbl-imba-2" ]; + id = "yjvni-9eaa7"; + }; + "Org" = { + path = "/Vault/data/syncthing/Org"; + devices = [ "sync (@oracle)" "magicant" "zenfone9" "nbl-imba-2" ]; + id = "a7xnl-zjj3d"; + }; + "Vpn" = { + path = "/Vault/data/syncthing/Vpn"; + devices = [ "sync (@oracle)" "magicant" "zenfone9" "nbl-imba-2" ]; + id = "hgp9s-fyq3p"; + }; + }; + }; + }; + + services.nginx = { + virtualHosts = { + "storync.swarsel.win" = { + enableACME = true; + forceSSL = true; + acmeRoot = null; + locations = { + "/" = { + proxyPass = "http://localhost:8384/"; + extraConfig = '' + client_max_body_size 0; + ''; + }; + }; + }; + }; + }; + + } +#+end_src + *** Optional :PROPERTIES: diff --git a/modules/nixos/setup.nix b/modules/nixos/setup.nix index 5828528..fd59da2 100644 --- a/modules/nixos/setup.nix +++ b/modules/nixos/setup.nix @@ -20,4 +20,5 @@ in options.swarselsystems.server.immich = lib.mkEnableOption "enable immich on server"; options.swarselsystems.server.paperless = lib.mkEnableOption "enable paperless on server"; options.swarselsystems.server.transmission = lib.mkEnableOption "enable transmission and friends on server"; + options.swarselsystems.server.syncthing = lib.mkEnableOption "enable syncthing on server"; } diff --git a/profiles/common/nixos/syncthing.nix b/profiles/common/nixos/syncthing.nix index 0c57c7e..bb27c96 100644 --- a/profiles/common/nixos/syncthing.nix +++ b/profiles/common/nixos/syncthing.nix @@ -9,6 +9,9 @@ _: settings = { devices = { "magicant" = { + id = "VMWGEE2-4HDS2QO-KNQOVGN-LXLX6LA-666E4EK-ZBRYRRO-XFEX6FB-6E3XLQO"; + }; + "zenfone9" = { id = "SEH2NMT-IVRQUU5-VPW2HUQ-3GQYDBF-F6H6OY6-X3DZTUZ-LCRE2DJ-QNIXIQ2"; }; "sync (@oracle)" = { @@ -21,22 +24,22 @@ _: folders = { "Default Folder" = { path = "/home/swarsel/Sync"; - devices = [ "sync (@oracle)" "magicant" ]; + devices = [ "sync (@oracle)" "magicant" "zenfone9" ]; id = "default"; }; "Obsidian" = { path = "/home/swarsel/Nextcloud/Obsidian"; - devices = [ "sync (@oracle)" "magicant" ]; + devices = [ "sync (@oracle)" "magicant" "zenfone9" ]; id = "yjvni-9eaa7"; }; "Org" = { path = "/home/swarsel/Nextcloud/Org"; - devices = [ "sync (@oracle)" "magicant" ]; + devices = [ "sync (@oracle)" "magicant" "zenfone9" ]; id = "a7xnl-zjj3d"; }; "Vpn" = { path = "/home/swarsel/Vpn"; - devices = [ "sync (@oracle)" "magicant" ]; + devices = [ "sync (@oracle)" "magicant" "zenfone9" ]; id = "hgp9s-fyq3p"; }; }; diff --git a/profiles/server/common/default.nix b/profiles/server/common/default.nix index 0a98054..fb5248d 100644 --- a/profiles/server/common/default.nix +++ b/profiles/server/common/default.nix @@ -23,6 +23,7 @@ ./immich.nix ./paperless.nix ./transmission.nix + ./syncthing.nix ]; nix = diff --git a/profiles/server/common/syncthing.nix b/profiles/server/common/syncthing.nix new file mode 100644 index 0000000..b46ee48 --- /dev/null +++ b/profiles/server/common/syncthing.nix @@ -0,0 +1,74 @@ +{ pkgs, lib, config, ... }: +{ + config = lib.mkIf config.swarselsystems.server.syncthing { + + users.users.syncthing = { + extraGroups = [ "users" ]; + }; + + services.syncthing = { + enable = true; + user = "syncthing"; + dataDir = "/Vault/data/syncthing"; + configDir = "/Vault/apps/syncthing"; + guiAddress = "0.0.0.0:8384"; + openDefaultPorts = true; + settings = { + devices = { + "magicant" = { + id = "VMWGEE2-4HDS2QO-KNQOVGN-LXLX6LA-666E4EK-ZBRYRRO-XFEX6FB-6E3XLQO"; + }; + "zenfone9" = { + id = "SEH2NMT-IVRQUU5-VPW2HUQ-3GQYDBF-F6H6OY6-X3DZTUZ-LCRE2DJ-QNIXIQ2"; + }; + "sync (@oracle)" = { + id = "ETW6TST-NPK7MKZ-M4LXMHA-QUPQHDT-VTSHH5X-CR5EIN2-YU7E55F-MGT7DQB"; + }; + "nbl-imba-2" = { + id = "YAPV4BV-I26WPTN-SIP32MV-SQP5TBZ-3CHMTCI-Z3D6EP2-MNDQGLP-53FT3AB"; + }; + }; + folders = { + "Default Folder" = { + path = "/Vault/data/syncthing/Sync"; + devices = [ "sync (@oracle)" "magicant" "zenfone9" "nbl-imba-2" ]; + id = "default"; + }; + "Obsidian" = { + path = "/Vault/data/syncthing/Obsidian"; + devices = [ "sync (@oracle)" "magicant" "zenfone9" "nbl-imba-2" ]; + id = "yjvni-9eaa7"; + }; + "Org" = { + path = "/Vault/data/syncthing/Org"; + devices = [ "sync (@oracle)" "magicant" "zenfone9" "nbl-imba-2" ]; + id = "a7xnl-zjj3d"; + }; + "Vpn" = { + path = "/Vault/data/syncthing/Vpn"; + devices = [ "sync (@oracle)" "magicant" "zenfone9" "nbl-imba-2" ]; + id = "hgp9s-fyq3p"; + }; + }; + }; + }; + + services.nginx = { + virtualHosts = { + "storync.swarsel.win" = { + enableACME = true; + forceSSL = true; + acmeRoot = null; + locations = { + "/" = { + proxyPass = "http://localhost:8384/"; + extraConfig = '' + client_max_body_size 0; + ''; + }; + }; + }; + }; + }; + + } diff --git a/profiles/server/winters/default.nix b/profiles/server/winters/default.nix index 1cd24d2..3c5a38b 100644 --- a/profiles/server/winters/default.nix +++ b/profiles/server/winters/default.nix @@ -52,6 +52,7 @@ immich = true; paperless = true; transmission = true; + syncthing = true; }; };