9 cfg = config.services.iperf3;
12 enable = mkEnableOption "iperf3 network throughput testing server";
13 package = mkPackageOption pkgs "iperf3" { };
15 type = types.ints.u16;
17 description = "Server port to listen on for iperf3 client requests.";
20 type = types.nullOr types.ints.unsigned;
22 description = "CPU affinity for the process.";
25 type = types.nullOr types.str;
27 description = "Bind to the specific interface associated with the given address.";
29 openFirewall = mkOption {
32 description = "Open ports in the firewall for iperf3.";
37 description = "Give more detailed output.";
39 forceFlush = mkOption {
42 description = "Force flushing output at every interval.";
47 description = "Emit debugging output.";
49 rsaPrivateKey = mkOption {
50 type = types.nullOr types.path;
52 description = "Path to the RSA private key (not password-protected) used to decrypt authentication credentials from the client.";
54 authorizedUsersFile = mkOption {
55 type = types.nullOr types.path;
57 description = "Path to the configuration file containing authorized users credentials to run iperf tests.";
59 extraFlags = mkOption {
60 type = types.listOf types.str;
62 description = "Extra flags to pass to iperf3(1).";
68 networking.firewall = mkIf cfg.openFirewall {
69 allowedTCPPorts = [ cfg.port ];
72 systemd.services.iperf3 = {
73 description = "iperf3 daemon";
74 unitConfig.Documentation = "man:iperf3(1) https://iperf.fr/iperf-doc.php";
75 wantedBy = [ "multi-user.target" ];
76 after = [ "network.target" ];
79 Restart = "on-failure";
82 PrivateDevices = true;
83 CapabilityBoundingSet = "";
84 NoNewPrivileges = true;
86 ${lib.getExe cfg.package} \
88 --port ${toString cfg.port} \
89 ${optionalString (cfg.affinity != null) "--affinity ${toString cfg.affinity}"} \
90 ${optionalString (cfg.bind != null) "--bind ${cfg.bind}"} \
91 ${optionalString (cfg.rsaPrivateKey != null) "--rsa-private-key-path ${cfg.rsaPrivateKey}"} \
94 cfg.authorizedUsersFile != null
95 ) "--authorized-users-path ${cfg.authorizedUsersFile}"
97 ${optionalString cfg.verbose "--verbose"} \
98 ${optionalString cfg.debug "--debug"} \
99 ${optionalString cfg.forceFlush "--forceflush"} \
100 ${escapeShellArgs cfg.extraFlags}
107 options.services.iperf3 = api;
108 config = mkIf cfg.enable imp;