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.
105 lines
2.6 KiB
Nix
105 lines
2.6 KiB
Nix
{ config, lib, pkgs, ... }:
|
|
|
|
with lib;
|
|
|
|
let
|
|
pkg = pkgs.ostinato;
|
|
cfg = config.services.ostinato;
|
|
configFile = pkgs.writeText "drone.ini" ''
|
|
[General]
|
|
RateAccuracy=${cfg.rateAccuracy}
|
|
|
|
[RpcServer]
|
|
Address=${cfg.rpcServer.address}
|
|
|
|
[PortList]
|
|
Include=${concatStringsSep "," cfg.portList.include}
|
|
Exclude=${concatStringsSep "," cfg.portList.exclude}
|
|
'';
|
|
|
|
in
|
|
{
|
|
|
|
###### interface
|
|
|
|
options = {
|
|
|
|
services.ostinato = {
|
|
|
|
enable = mkEnableOption "Ostinato agent-controller (Drone)";
|
|
|
|
port = mkOption {
|
|
type = types.int;
|
|
default = 7878;
|
|
description = lib.mdDoc ''
|
|
Port to listen on.
|
|
'';
|
|
};
|
|
|
|
rateAccuracy = mkOption {
|
|
type = types.enum [ "High" "Low" ];
|
|
default = "High";
|
|
description = lib.mdDoc ''
|
|
To ensure that the actual transmit rate is as close as possible to
|
|
the configured transmit rate, Drone runs a busy-wait loop.
|
|
While this provides the maximum accuracy possible, the CPU
|
|
utilization is 100% while the transmit is on. You can however,
|
|
sacrifice the accuracy to reduce the CPU load.
|
|
'';
|
|
};
|
|
|
|
rpcServer = {
|
|
address = mkOption {
|
|
type = types.str;
|
|
default = "0.0.0.0";
|
|
description = lib.mdDoc ''
|
|
By default, the Drone RPC server will listen on all interfaces and
|
|
local IPv4 adresses for incoming connections from clients. Specify
|
|
a single IPv4 or IPv6 address if you want to restrict that.
|
|
To listen on any IPv6 address, use ::
|
|
'';
|
|
};
|
|
};
|
|
|
|
portList = {
|
|
include = mkOption {
|
|
type = types.listOf types.str;
|
|
default = [];
|
|
example = [ "eth*" "lo*" ];
|
|
description = lib.mdDoc ''
|
|
For a port to pass the filter and appear on the port list managed
|
|
by drone, it be allowed by this include list.
|
|
'';
|
|
};
|
|
exclude = mkOption {
|
|
type = types.listOf types.str;
|
|
default = [];
|
|
example = [ "usbmon*" "eth0" ];
|
|
description = lib.mdDoc ''
|
|
A list of ports does not appear on the port list managed by drone.
|
|
'';
|
|
};
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
###### implementation
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
environment.systemPackages = [ pkg ];
|
|
|
|
systemd.services.drone = {
|
|
description = "Ostinato agent-controller";
|
|
wantedBy = [ "multi-user.target" ];
|
|
script = ''
|
|
${pkg}/bin/drone ${toString cfg.port} ${configFile}
|
|
'';
|
|
};
|
|
|
|
};
|
|
|
|
}
|