forked from mirrors/nixpkgs
2e751c0772
the conversion procedure is simple: - find all things that look like options, ie calls to either `mkOption` or `lib.mkOption` that take an attrset. remember the attrset as the option - for all options, find a `description` attribute who's value is not a call to `mdDoc` or `lib.mdDoc` - textually convert the entire value of the attribute to MD with a few simple regexes (the set from mdize-module.sh) - if the change produced a change in the manual output, discard - if the change kept the manual unchanged, add some text to the description to make sure we've actually found an option. if the manual changes this time, keep the converted description this procedure converts 80% of nixos options to markdown. around 2000 options remain to be inspected, but most of those fail the "does not change the manual output check": currently the MD conversion process does not faithfully convert docbook tags like <code> and <package>, so any option using such tags will not be converted at all.
91 lines
2.7 KiB
Nix
91 lines
2.7 KiB
Nix
{ lib, pkgs, config, ... }:
|
|
|
|
with lib;
|
|
|
|
let
|
|
pkg = pkgs.tox-node;
|
|
cfg = config.services.tox-node;
|
|
homeDir = "/var/lib/tox-node";
|
|
|
|
configFile = let
|
|
src = "${pkg.src}/dpkg/config.yml";
|
|
confJSON = pkgs.writeText "config.json" (
|
|
builtins.toJSON {
|
|
log-type = cfg.logType;
|
|
keys-file = cfg.keysFile;
|
|
udp-address = cfg.udpAddress;
|
|
tcp-addresses = cfg.tcpAddresses;
|
|
tcp-connections-limit = cfg.tcpConnectionLimit;
|
|
lan-discovery = cfg.lanDiscovery;
|
|
threads = cfg.threads;
|
|
motd = cfg.motd;
|
|
}
|
|
);
|
|
in with pkgs; runCommand "config.yml" {} ''
|
|
${remarshal}/bin/remarshal -if yaml -of json ${src} -o src.json
|
|
${jq}/bin/jq -s '(.[0] | with_entries( select(.key == "bootstrap-nodes"))) * .[1]' src.json ${confJSON} > $out
|
|
'';
|
|
|
|
in {
|
|
options.services.tox-node = {
|
|
enable = mkEnableOption "Tox Node service";
|
|
|
|
logType = mkOption {
|
|
type = types.enum [ "Stderr" "Stdout" "Syslog" "None" ];
|
|
default = "Stderr";
|
|
description = lib.mdDoc "Logging implementation.";
|
|
};
|
|
keysFile = mkOption {
|
|
type = types.str;
|
|
default = "${homeDir}/keys";
|
|
description = lib.mdDoc "Path to the file where DHT keys are stored.";
|
|
};
|
|
udpAddress = mkOption {
|
|
type = types.str;
|
|
default = "0.0.0.0:33445";
|
|
description = lib.mdDoc "UDP address to run DHT node.";
|
|
};
|
|
tcpAddresses = mkOption {
|
|
type = types.listOf types.str;
|
|
default = [ "0.0.0.0:33445" ];
|
|
description = lib.mdDoc "TCP addresses to run TCP relay.";
|
|
};
|
|
tcpConnectionLimit = mkOption {
|
|
type = types.int;
|
|
default = 8192;
|
|
description = lib.mdDoc "Maximum number of active TCP connections relay can hold";
|
|
};
|
|
lanDiscovery = mkOption {
|
|
type = types.bool;
|
|
default = true;
|
|
description = lib.mdDoc "Enable local network discovery.";
|
|
};
|
|
threads = mkOption {
|
|
type = types.int;
|
|
default = 1;
|
|
description = lib.mdDoc "Number of threads for execution";
|
|
};
|
|
motd = mkOption {
|
|
type = types.str;
|
|
default = "Hi from tox-rs! I'm up {{uptime}}. TCP: incoming {{tcp_packets_in}}, outgoing {{tcp_packets_out}}, UDP: incoming {{udp_packets_in}}, outgoing {{udp_packets_out}}";
|
|
description = lib.mdDoc "Message of the day";
|
|
};
|
|
};
|
|
|
|
config = lib.mkIf cfg.enable {
|
|
systemd.services.tox-node = {
|
|
description = "Tox Node";
|
|
|
|
after = [ "network.target" ];
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
serviceConfig = {
|
|
ExecStart = "${pkg}/bin/tox-node config ${configFile}";
|
|
StateDirectory = "tox-node";
|
|
DynamicUser = true;
|
|
Restart = "always";
|
|
};
|
|
};
|
|
};
|
|
}
|