python3Packages.orjson: Disable failing tests on 32 bit
[NixPkgs.git] / nixos / modules / services / networking / tox-bootstrapd.nix
blob5c7e7a4c22082209f06b221b91e9a1a85cd31920
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               lib.mdDoc ''
27                 Whether to enable the Tox DHT bootstrap daemon.
28               '';
29           };
31           port = mkOption {
32             type = types.port;
33             default = 33445;
34             description = lib.mdDoc "Listening port (UDP).";
35           };
37           keysFile = mkOption {
38             type = types.str;
39             default = "${WorkingDirectory}/keys";
40             description = lib.mdDoc "Node key file.";
41           };
43           extraConfig = mkOption {
44             type = types.lines;
45             default = "";
46             description =
47               lib.mdDoc ''
48                 Configuration for bootstrap daemon.
49                 See <https://github.com/irungentoo/toxcore/blob/master/other/bootstrap_daemon/tox-bootstrapd.conf>
50                 and <http://wiki.tox.im/Nodes>.
51              '';
52           };
53       };
55     };
57   config = mkIf config.services.toxBootstrapd.enable {
59     systemd.services.tox-bootstrapd = {
60       description = "Tox DHT bootstrap daemon";
61       after = [ "network.target" ];
62       wantedBy = [ "multi-user.target" ];
63       serviceConfig =
64         { ExecStart = "${pkg}/bin/tox-bootstrapd --config=${cfgFile}";
65           Type = "forking";
66           inherit PIDFile WorkingDirectory;
67           AmbientCapabilities = ["CAP_NET_BIND_SERVICE"];
68           DynamicUser = true;
69           StateDirectory = "tox-bootstrapd";
70         };
71     };
73   };