at 25.11-pre 2.7 kB view raw
1{ 2 config, 3 lib, 4 pkgs, 5 ... 6}: 7 8with lib; 9 10let 11 pkg = pkgs.ostinato; 12 cfg = config.services.ostinato; 13 configFile = pkgs.writeText "drone.ini" '' 14 [General] 15 RateAccuracy=${cfg.rateAccuracy} 16 17 [RpcServer] 18 Address=${cfg.rpcServer.address} 19 20 [PortList] 21 Include=${concatStringsSep "," cfg.portList.include} 22 Exclude=${concatStringsSep "," cfg.portList.exclude} 23 ''; 24 25in 26{ 27 28 ###### interface 29 30 options = { 31 32 services.ostinato = { 33 34 enable = mkEnableOption "Ostinato agent-controller (Drone)"; 35 36 port = mkOption { 37 type = types.port; 38 default = 7878; 39 description = '' 40 Port to listen on. 41 ''; 42 }; 43 44 rateAccuracy = mkOption { 45 type = types.enum [ 46 "High" 47 "Low" 48 ]; 49 default = "High"; 50 description = '' 51 To ensure that the actual transmit rate is as close as possible to 52 the configured transmit rate, Drone runs a busy-wait loop. 53 While this provides the maximum accuracy possible, the CPU 54 utilization is 100% while the transmit is on. You can however, 55 sacrifice the accuracy to reduce the CPU load. 56 ''; 57 }; 58 59 rpcServer = { 60 address = mkOption { 61 type = types.str; 62 default = "0.0.0.0"; 63 description = '' 64 By default, the Drone RPC server will listen on all interfaces and 65 local IPv4 addresses for incoming connections from clients. Specify 66 a single IPv4 or IPv6 address if you want to restrict that. 67 To listen on any IPv6 address, use :: 68 ''; 69 }; 70 }; 71 72 portList = { 73 include = mkOption { 74 type = types.listOf types.str; 75 default = [ ]; 76 example = [ 77 "eth*" 78 "lo*" 79 ]; 80 description = '' 81 For a port to pass the filter and appear on the port list managed 82 by drone, it be allowed by this include list. 83 ''; 84 }; 85 exclude = mkOption { 86 type = types.listOf types.str; 87 default = [ ]; 88 example = [ 89 "usbmon*" 90 "eth0" 91 ]; 92 description = '' 93 A list of ports does not appear on the port list managed by drone. 94 ''; 95 }; 96 }; 97 98 }; 99 100 }; 101 102 ###### implementation 103 104 config = mkIf cfg.enable { 105 106 environment.systemPackages = [ pkg ]; 107 108 systemd.services.drone = { 109 description = "Ostinato agent-controller"; 110 wantedBy = [ "multi-user.target" ]; 111 script = '' 112 ${pkg}/bin/drone ${toString cfg.port} ${configFile} 113 ''; 114 }; 115 116 }; 117 118}