at 25.11-pre 1.8 kB view raw
1{ 2 config, 3 lib, 4 pkgs, 5 ... 6}: 7 8with lib; 9 10let 11 WorkingDirectory = "/var/lib/tox-bootstrapd"; 12 PIDFile = "${WorkingDirectory}/pid"; 13 14 pkg = pkgs.libtoxcore; 15 cfg = config.services.toxBootstrapd; 16 cfgFile = builtins.toFile "tox-bootstrapd.conf" '' 17 port = ${toString cfg.port} 18 keys_file_path = "${WorkingDirectory}/keys" 19 pid_file_path = "${PIDFile}" 20 ${cfg.extraConfig} 21 ''; 22in 23{ 24 options = { 25 services.toxBootstrapd = { 26 enable = mkOption { 27 type = types.bool; 28 default = false; 29 description = '' 30 Whether to enable the Tox DHT bootstrap daemon. 31 ''; 32 }; 33 34 port = mkOption { 35 type = types.port; 36 default = 33445; 37 description = "Listening port (UDP)."; 38 }; 39 40 keysFile = mkOption { 41 type = types.str; 42 default = "${WorkingDirectory}/keys"; 43 description = "Node key file."; 44 }; 45 46 extraConfig = mkOption { 47 type = types.lines; 48 default = ""; 49 description = '' 50 Configuration for bootstrap daemon. 51 See <https://github.com/irungentoo/toxcore/blob/master/other/bootstrap_daemon/tox-bootstrapd.conf> 52 and <https://wiki.tox.chat/users/nodes>. 53 ''; 54 }; 55 }; 56 57 }; 58 59 config = mkIf config.services.toxBootstrapd.enable { 60 61 systemd.services.tox-bootstrapd = { 62 description = "Tox DHT bootstrap daemon"; 63 after = [ "network.target" ]; 64 wantedBy = [ "multi-user.target" ]; 65 serviceConfig = { 66 ExecStart = "${pkg}/bin/tox-bootstrapd --config=${cfgFile}"; 67 Type = "forking"; 68 inherit PIDFile WorkingDirectory; 69 AmbientCapabilities = [ "CAP_NET_BIND_SERVICE" ]; 70 DynamicUser = true; 71 StateDirectory = "tox-bootstrapd"; 72 }; 73 }; 74 75 }; 76}