add syncthing included dir option

This commit is contained in:
Yan Lin 2025-11-02 21:37:15 +01:00
parent 0d77068f9f
commit 061d5bf544
2 changed files with 53 additions and 25 deletions

View file

@ -16,6 +16,9 @@
# Always show GNOME top bar on Steam Deck # Always show GNOME top bar on Steam Deck
gnome-custom.alwaysShowTopBar = true; gnome-custom.alwaysShowTopBar = true;
# Disable Documents sync on Steam Deck (save space)
syncthing-custom.enabledFolders = [ "Credentials" "Obsidian" ];
# Enable Ghostty terminal with OSC-52 clipboard support # Enable Ghostty terminal with OSC-52 clipboard support
programs.ghostty-custom = { programs.ghostty-custom = {
enable = true; enable = true;

View file

@ -1,6 +1,8 @@
{ config, pkgs, lib, ... }: { config, pkgs, lib, ... }:
let let
cfg = config.syncthing-custom;
# Common ignore patterns for all synced folders # Common ignore patterns for all synced folders
commonIgnores = [ commonIgnores = [
".DS_Store" ".DS_Store"
@ -28,6 +30,15 @@ let
}; };
in in
{ {
options.syncthing-custom = {
enabledFolders = lib.mkOption {
type = lib.types.listOf lib.types.str;
default = [ "Credentials" "Documents" "Obsidian" ];
description = "List of Syncthing folders to enable for this host. Available: Credentials, Documents, Obsidian";
};
};
config = {
# Enable Syncthing service # Enable Syncthing service
services.syncthing = { services.syncthing = {
enable = true; enable = true;
@ -58,27 +69,32 @@ in
}; };
}; };
# Define shared folders # Define shared folders (only enabled ones)
folders = { folders =
"Credentials" = { (lib.optionalAttrs (lib.elem "Credentials" cfg.enabledFolders) {
path = "~/Credentials"; "Credentials" = {
devices = [ "iphone" "hs" "thinkpad" "deck" ]; path = "~/Credentials";
ignorePerms = true; devices = [ "iphone" "hs" "thinkpad" "deck" ];
versioning = commonVersioning; ignorePerms = true;
}; versioning = commonVersioning;
"Documents" = { };
path = "~/Documents"; })
devices = [ "hs" "thinkpad" "deck" ]; // (lib.optionalAttrs (lib.elem "Documents" cfg.enabledFolders) {
ignorePerms = true; "Documents" = {
versioning = commonVersioning; path = "~/Documents";
}; devices = [ "hs" "thinkpad" ];
"Obsidian" = { ignorePerms = true;
path = "~/Obsidian"; versioning = commonVersioning;
devices = [ "iphone" "hs" "thinkpad" "deck" ]; };
ignorePerms = true; })
versioning = commonVersioning; // (lib.optionalAttrs (lib.elem "Obsidian" cfg.enabledFolders) {
}; "Obsidian" = {
}; path = "~/Obsidian";
devices = [ "iphone" "hs" "thinkpad" "deck" ];
ignorePerms = true;
versioning = commonVersioning;
};
});
# GUI settings with authentication # GUI settings with authentication
gui = { gui = {
@ -98,12 +114,21 @@ in
}; };
}; };
# Deploy .stignore files to synced folders # Deploy .stignore files to synced folders (only for enabled folders)
home.file."Credentials/.stignore".text = stignoreContent; home.file = lib.mkMerge [
home.file."Documents/.stignore".text = stignoreContent; (lib.mkIf (lib.elem "Credentials" cfg.enabledFolders) {
home.file."Obsidian/.stignore".text = stignoreContent; "Credentials/.stignore".text = stignoreContent;
})
(lib.mkIf (lib.elem "Documents" cfg.enabledFolders) {
"Documents/.stignore".text = stignoreContent;
})
(lib.mkIf (lib.elem "Obsidian" cfg.enabledFolders) {
"Obsidian/.stignore".text = stignoreContent;
})
];
# For NixOS systems, we need to add Syncthing as a manual service in Traefik # For NixOS systems, we need to add Syncthing as a manual service in Traefik
# Since Syncthing runs as a systemd service (not container), we'll handle routing via static config # Since Syncthing runs as a systemd service (not container), we'll handle routing via static config
# or create a container wrapper for it to use with service discovery # or create a container wrapper for it to use with service discovery
};
} }