2020-04-24 23:36:52 +00:00
|
|
|
{ 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 = {
|
|
|
|
|
2022-09-09 14:08:57 +00:00
|
|
|
enable = mkEnableOption (lib.mdDoc "Ostinato agent-controller (Drone)");
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
port = mkOption {
|
2022-11-21 17:40:18 +00:00
|
|
|
type = types.port;
|
2020-04-24 23:36:52 +00:00
|
|
|
default = 7878;
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc ''
|
2020-04-24 23:36:52 +00:00
|
|
|
Port to listen on.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
rateAccuracy = mkOption {
|
|
|
|
type = types.enum [ "High" "Low" ];
|
|
|
|
default = "High";
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc ''
|
2020-04-24 23:36:52 +00:00
|
|
|
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";
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc ''
|
2020-04-24 23:36:52 +00:00
|
|
|
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 = [];
|
2021-10-06 13:57:05 +00:00
|
|
|
example = [ "eth*" "lo*" ];
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc ''
|
2020-04-24 23:36:52 +00:00
|
|
|
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 = [];
|
2021-10-06 13:57:05 +00:00
|
|
|
example = [ "usbmon*" "eth0" ];
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc ''
|
2020-04-24 23:36:52 +00:00
|
|
|
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}
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|