diff options
Diffstat (limited to '')
-rw-r--r-- | modules/nixos/syncthing.nix | 62 |
1 files changed, 34 insertions, 28 deletions
diff --git a/modules/nixos/syncthing.nix b/modules/nixos/syncthing.nix index ecc983f..74d4afe 100644 --- a/modules/nixos/syncthing.nix +++ b/modules/nixos/syncthing.nix @@ -6,9 +6,11 @@ this, ... }: -with lib; let +with lib; +let cfg = config.nixfiles.modules.syncthing; -in { +in +{ options.nixfiles.modules.syncthing = { enable = mkEnableOption "Syncthing"; @@ -74,7 +76,8 @@ in { insecureSkipHostcheck = this.isHeadless; }; - devices = mapAttrs (name: attr: + devices = mapAttrs ( + name: attr: mkIf (attr.syncthing.id != null && hasAttr "wireguard" attr) { inherit (attr.syncthing) id; compression = "metadata"; @@ -82,30 +85,33 @@ in { address = "tcp://${name}.${config.networking.domain}:22000"; autoAcceptFolders = true; untrusted = false; - }) - my.configurations; - - folders = let - filterDevices = f: - attrNames (filterAttrs (_: attr: - (attr.hostname != this.hostname) - && (attr.syncthing.id != null) - && f attr) - my.configurations); - all = filterDevices (_: true); - notHeadless = filterDevices (attr: !attr.isHeadless); - notOther = filterDevices (attr: !attr.isOther); - - simple = { - type = "simple"; - params.keep = "5"; - }; - trashcan = { - type = "trashcan"; - params.cleanoutDays = "7"; - }; - in - with config.hm.xdg.userDirs; { + } + ) my.configurations; + + folders = + let + filterDevices = + f: + attrNames ( + filterAttrs ( + _: attr: (attr.hostname != this.hostname) && (attr.syncthing.id != null) && f attr + ) my.configurations + ); + all = filterDevices (_: true); + notHeadless = filterDevices (attr: !attr.isHeadless); + notOther = filterDevices (attr: !attr.isOther); + + simple = { + type = "simple"; + params.keep = "5"; + }; + trashcan = { + type = "trashcan"; + params.cleanoutDays = "7"; + }; + in + with config.hm.xdg.userDirs; + { share = { path = publicShare; devices = notHeadless; @@ -145,7 +151,7 @@ in { (mkIf this.isHeadless { nixfiles.modules.nginx = { enable = true; - upstreams.syncthing.servers.${config.services.syncthing.guiAddress} = {}; + upstreams.syncthing.servers.${config.services.syncthing.guiAddress} = { }; virtualHosts.${cfg.domain} = { locations."/".proxyPass = "http://syncthing"; extraConfig = libNginx.config.internalOnly; |