1 { config, lib, pkgs, ... }:
7 cfg = config.services.xinetd;
9 configFile = pkgs.writeText "xinetd.conf"
13 log_type = SYSLOG daemon info
15 log_on_success = PID HOST DURATION EXIT
19 ${concatMapStrings makeService cfg.services}
26 protocol = ${srv.protocol}
27 ${optionalString srv.unlisted "type = UNLISTED"}
28 ${optionalString (srv.flags != "") "flags = ${srv.flags}"}
29 socket_type = ${if srv.protocol == "udp" then "dgram" else "stream"}
30 ${optionalString (srv.port != 0) "port = ${toString srv.port}"}
31 wait = ${if srv.protocol == "udp" then "yes" else "no"}
33 server = ${srv.server}
34 ${optionalString (srv.serverArgs != "") "server_args = ${srv.serverArgs}"}
47 services.xinetd.enable = mkEnableOption "the xinetd super-server daemon";
49 services.xinetd.extraDefaults = mkOption {
53 Additional configuration lines added to the default section of xinetd's configuration.
57 services.xinetd.services = mkOption {
60 A list of services provided by xinetd.
63 type = with types; listOf (submodule ({
70 description = "Name of the service.";
76 description = "Protocol of the service. Usually `tcp` or `udp`.";
83 description = "Port number of the service.";
89 description = "User account for the service";
94 example = "/foo/bin/ftpd";
95 description = "Path of the program that implements the service.";
98 serverArgs = mkOption {
99 type = types.separatedString " ";
101 description = "Command-line arguments for the server program.";
110 unlisted = mkOption {
114 Whether this server is listed in
115 {file}`/etc/services`. If so, the port
116 number can be omitted.
120 extraConfig = mkOption {
123 description = "Extra configuration-lines added to the section of the service.";
135 ###### implementation
137 config = mkIf cfg.enable {
138 systemd.services.xinetd = {
139 description = "xinetd server";
140 after = [ "network.target" ];
141 wantedBy = [ "multi-user.target" ];
142 path = [ pkgs.xinetd ];
143 script = "exec xinetd -syslog daemon -dontfork -stayalive -f ${configFile}";