add syncthing to vps

This commit is contained in:
Yan Lin 2025-12-03 13:45:30 +01:00
parent a3d1f59c43
commit c18309aead
2 changed files with 17 additions and 7 deletions

View file

@ -3,5 +3,11 @@
{ {
imports = [ imports = [
../home-default.nix ../home-default.nix
../../../modules/syncthing.nix
]; ];
syncthing-custom = {
enabledFolders = [ "Credentials" ];
enableGui = false;
};
} }

View file

@ -22,11 +22,10 @@ let
stignoreContent = lib.concatStringsSep "\n" commonIgnores; stignoreContent = lib.concatStringsSep "\n" commonIgnores;
# Device groupings # Device groupings
nixosDevices = [ "hs" "thinkpad" ]; pcDevices = [ "macbook" "hs" "thinkpad" ];
darwinDevices = [ "macbook" ];
touchDevices = [ "iphone" "ipad" ]; touchDevices = [ "iphone" "ipad" ];
pcDevices = nixosDevices ++ darwinDevices; cloudDevices = [ "vps" ];
allDevices = pcDevices ++ touchDevices; allDevices = pcDevices ++ touchDevices ++ cloudDevices;
# Common versioning configuration # Common versioning configuration
commonVersioning = { commonVersioning = {
@ -44,6 +43,11 @@ in
default = [ "Credentials" "Documents" "Archive" ]; default = [ "Credentials" "Documents" "Archive" ];
description = "List of Syncthing folders to enable for this host."; description = "List of Syncthing folders to enable for this host.";
}; };
enableGui = lib.mkOption {
type = lib.types.bool;
default = true;
description = "Whether to enable the Syncthing web GUI.";
};
}; };
config = { config = {
@ -54,7 +58,7 @@ in
tray.enable = false; tray.enable = false;
# Listen on all interfaces for the GUI # Listen on all interfaces for the GUI
guiAddress = "0.0.0.0:8384"; guiAddress = lib.mkIf cfg.enableGui "0.0.0.0:8384";
# Declarative configuration - will override any GUI changes # Declarative configuration - will override any GUI changes
overrideDevices = true; overrideDevices = true;
@ -101,7 +105,7 @@ in
// (lib.optionalAttrs (lib.elem "Archive" cfg.enabledFolders) { // (lib.optionalAttrs (lib.elem "Archive" cfg.enabledFolders) {
"Archive" = { "Archive" = {
path = "~/Archive"; path = "~/Archive";
devices = allDevices; devices = pcDevices ++ touchDevices;
ignorePerms = true; ignorePerms = true;
versioning = commonVersioning; versioning = commonVersioning;
}; };
@ -109,7 +113,7 @@ in
# GUI settings with authentication # GUI settings with authentication
gui = { gui = {
enabled = true; enabled = cfg.enableGui;
user = "yanlin"; user = "yanlin";
useTLS = false; useTLS = false;
}; };