From 8fa2b12384df3b36b0b7ba4a2ed36cf899f35b45 Mon Sep 17 00:00:00 2001 From: tv Date: Sat, 15 Sep 2018 09:19:05 +0200 Subject: WIP --- krebs/3modules/syncthing.nix | 232 ++++++++++++++++++++++++++++--------------- 1 file changed, 153 insertions(+), 79 deletions(-) diff --git a/krebs/3modules/syncthing.nix b/krebs/3modules/syncthing.nix index e485c073c..4bd526dae 100644 --- a/krebs/3modules/syncthing.nix +++ b/krebs/3modules/syncthing.nix @@ -1,97 +1,74 @@ -{ config, lib, pkgs, ... }: +with import ; +{ config, pkgs, ... }: let -with lib; + cfg = config.krebs.syncthing; -let - cfg = config.services.syncthing; - defaultUser = "syncthing"; in { - ###### interface - options = { - services.syncthing = { - - enable = mkEnableOption '' - Syncthing - the self-hosted open-source alternative - to Dropbox and Bittorrent Sync. Initial interface will be - available on http://127.0.0.1:8384/. - ''; - systemService = mkOption { - type = types.bool; - default = true; - description = "Auto launch Syncthing as a system service."; - }; + options.krebs.syncthing = { - user = mkOption { - type = types.string; - default = defaultUser; - description = '' - Syncthing will be run under this user (user will be created if it doesn't exist. - This can be your user name). - ''; - }; + enable = mkEnableOption "krebs.syncthing"; - group = mkOption { - type = types.string; - default = "nogroup"; - description = '' - Syncthing will be run under this group (group will not be created if it doesn't exist. - This can be your user name). - ''; - }; + systemService = mkOption { + type = types.bool; + default = true; + description = "Auto launch Syncthing as a system service."; + }; - all_proxy = mkOption { - type = types.nullOr types.string; - default = null; - example = "socks5://address.com:1234"; - description = '' - Overwrites all_proxy environment variable for the syncthing process to - the given value. This is normaly used to let relay client connect - through SOCKS5 proxy server. - ''; + user = mkOption { + type = types.user; + default = { + name = "syncthing"; + home = "/var/lib/syncthing"; }; + }; - dataDir = mkOption { - type = types.path; - default = "/var/lib/syncthing"; - description = '' - Path where the settings and keys will exist. - ''; + group = mkOption { + type = types.group; + default = { + name = "syncthing"; }; + }; - openDefaultPorts = mkOption { - type = types.bool; - default = false; - example = literalExample "true"; - description = '' - Open the default ports in the firewall: - - TCP 22000 for transfers - - UDP 21027 for discovery - If multiple users are running syncthing on this machine, you will need to manually open a set of ports for each instance and leave this disabled. - Alternatively, if are running only a single instance on this machine using the default ports, enable this. - ''; - }; + all_proxy = mkOption { + type = types.nullOr types.string; + default = null; + example = "socks5://address.com:1234"; + description = '' + Overwrites all_proxy environment variable for the syncthing process to + the given value. This is normaly used to let relay client connect + through SOCKS5 proxy server. + ''; + }; - package = mkOption { - type = types.package; - default = pkgs.syncthing; - defaultText = "pkgs.syncthing"; - example = literalExample "pkgs.syncthing"; - description = '' - Syncthing package to use. - ''; - }; + dataDir = mkOption { + type = types.path; + default = cfg.user.home; }; - }; - imports = [ - (mkRemovedOptionModule ["services" "syncthing" "useInotify"] '' - This option was removed because syncthing now has the inotify functionality included under the name "fswatcher". - It can be enabled on a per-folder basis through the webinterface. - '') - ]; + openDefaultPorts = mkOption { + type = types.bool; + default = false; + example = literalExample "true"; + description = '' + Open the default ports in the firewall: + - TCP 22000 for transfers + - UDP 21027 for discovery + If multiple users are running syncthing on this machine, you will need to manually open a set of ports for each instance and leave this disabled. + Alternatively, if are running only a single instance on this machine using the default ports, enable this. + ''; + }; - ###### implementation + package = mkOption { + type = types.package; + default = pkgs.syncthing; + defaultText = "pkgs.syncthing"; + example = literalExample "pkgs.syncthing"; + description = '' + Syncthing package to use. + ''; + }; + }; config = mkIf cfg.enable { @@ -142,3 +119,100 @@ in { }; }; } + + + + + + +# services.syncthing = { +# enable = true; +# dataDir = +## drwxr-xr-x 1 syncthing nogroup 78 Sep 11 20:12 index-v0.14.0.db +## drwxr-xr-x 1 syncthing nogroup 18 Sep 11 20:12 Sync +## -rw-r--r-- 1 syncthing nogroup 619 Sep 11 20:12 cert.pem +## -rw------- 1 syncthing nogroup 3.5K Sep 11 20:13 config.xml +## -rw------- 1 syncthing nogroup 33 Sep 11 20:13 csrftokens.txt +## -rw-r--r-- 1 syncthing nogroup 1.1K Sep 11 20:12 https-cert.pem +## -rw------- 1 syncthing nogroup 1.7K Sep 11 20:12 https-key.pem +## -rw------- 1 syncthing nogroup 288 Sep 11 20:12 key.pem +# +# #dataDir = "/var/lib/syncthing"; +# #group = "nogroup"; +# systemService = true; +# #user = "syncthing"; +# }; + +/* + + + basic + + 1 + + 0 + 0 + 0 + random + false + 0 + 0 + -1 + false + false + false + 25 + .stfolder + + +
dynamic
+ false + false +
+ +
127.0.0.1:8384
+ wPjcG4LurZgdxYVfrS7Ra5oa4w577mCs + default +
+ + default + default + true + true + 21027 + [ff12::8384]:21027 + 0 + 0 + 60 + true + 10 + true + true + 60 + 30 + 10 + -1 + 3 + ryNit35r + https://data.syncthing.net/newdata + false + 1800 + true + 12 + false + 24 + false + 5 + false + 1 + https://upgrades.syncthing.net/meta.json + false + 10 + 0 + auto + ~ + true + 0 + +
+*/ -- cgit v1.2.3