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