From 6ba7fd28d5f5c593ead1547c723e77ae8bac08f5 Mon Sep 17 00:00:00 2001 From: hektor Date: Sat, 7 Feb 2026 14:54:38 +0100 Subject: [PATCH] fix: simplify syncthing module --- hosts/andromache/default.nix | 21 +------------- hosts/astyanax/default.nix | 26 ++--------------- modules/syncthing/default.nix | 54 +---------------------------------- 3 files changed, 4 insertions(+), 97 deletions(-) diff --git a/hosts/andromache/default.nix b/hosts/andromache/default.nix index ba8582a..cf3170f 100644 --- a/hosts/andromache/default.nix +++ b/hosts/andromache/default.nix @@ -114,26 +114,7 @@ in }; }; - my.syncthing = { - enable = true; - deviceNames = [ - "boox" - "astyanax" - ]; - folders = { - readings = { - path = "/home/h/doc/readings"; - id = "readings"; - devices = [ - { - device = "boox"; - type = "receiveonly"; - } - "astyanax" - ]; - }; - }; - }; + my.syncthing.enable = true; networking = { # TODO: generate unique hostId on actual host with: head -c 8 /etc/machine-id diff --git a/hosts/astyanax/default.nix b/hosts/astyanax/default.nix index 57b9bf9..4f8531b 100644 --- a/hosts/astyanax/default.nix +++ b/hosts/astyanax/default.nix @@ -105,33 +105,11 @@ in enable = true; harden = true; }; - }; - - my.syncthing = { - enable = true; - deviceNames = [ - "boox" - "andromache" - ]; - folders = { - readings = { - path = "/home/h/doc/readings"; - id = "readings"; - devices = [ - { - device = "boox"; - type = "receiveonly"; - } - "andromache" - ]; - }; - }; - }; - - services = { locate = { enable = true; package = pkgs.plocate; }; }; + + my.syncthing.enable = true; } diff --git a/modules/syncthing/default.nix b/modules/syncthing/default.nix index ed8ce77..890cbc5 100644 --- a/modules/syncthing/default.nix +++ b/modules/syncthing/default.nix @@ -8,7 +8,6 @@ with lib; let cfg = config.my.syncthing; - allDevices = import ./devices.nix; in { options.my.syncthing = { @@ -17,41 +16,11 @@ in type = types.str; default = "h"; }; - deviceNames = mkOption { - type = types.listOf types.str; - default = [ ]; - }; - folders = mkOption { - type = types.attrsOf ( - types.submodule { - options = { - path = mkOption { type = types.path; }; - id = mkOption { type = types.str; }; - devices = mkOption { - type = types.listOf ( - types.either types.str ( - types.submodule { - options = { - device = mkOption { type = types.str; }; - type = mkOption { - type = types.str; - default = "sendreceive"; - }; - }; - } - ) - ); - default = cfg.deviceNames; - }; - }; - } - ); - default = { }; - }; }; config = mkIf cfg.enable { users.groups.${cfg.username} = { }; + users.users.${cfg.username}.extraGroups = [ cfg.username ]; services.syncthing = { enable = true; @@ -59,27 +28,6 @@ in group = cfg.username; configDir = "/home/${cfg.username}/.local/state/syncthing"; openDefaultPorts = true; - settings = { - options = { - localAnnounceEnabled = true; - globalAnnounceEnabled = true; - relaysEnabled = true; - urAccepted = -1; - }; - devices = mapAttrs (name: id: { inherit id; }) ( - filterAttrs (name: _: elem name cfg.deviceNames) allDevices - ); - folders = mapAttrs (name: folder: { - inherit (folder) id path; - devices = map ( - device: - if isString device then - allDevices.${device} - else - device // { deviceID = allDevices.${device.device}; } - ) folder.devices; - }) cfg.folders; - }; }; }; }