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 ${if srv.port != 0 then "port = ${toString srv.port}" else ""}
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 (lib.mdDoc "the xinetd super-server daemon");
49 services.xinetd.extraDefaults = mkOption {
52 description = lib.mdDoc ''
53 Additional configuration lines added to the default section of xinetd's configuration.
57 services.xinetd.services = mkOption {
59 description = lib.mdDoc ''
60 A list of services provided by xinetd.
63 type = with types; listOf (submodule ({
70 description = lib.mdDoc "Name of the service.";
77 lib.mdDoc "Protocol of the service. Usually `tcp` or `udp`.";
84 description = lib.mdDoc "Port number of the service.";
90 description = lib.mdDoc "User account for the service";
95 example = "/foo/bin/ftpd";
96 description = lib.mdDoc "Path of the program that implements the service.";
99 serverArgs = mkOption {
100 type = types.separatedString " ";
102 description = lib.mdDoc "Command-line arguments for the server program.";
108 description = lib.mdDoc "";
111 unlisted = mkOption {
114 description = lib.mdDoc ''
115 Whether this server is listed in
116 {file}`/etc/services`. If so, the port
117 number can be omitted.
121 extraConfig = mkOption {
124 description = lib.mdDoc "Extra configuration-lines added to the section of the service.";
136 ###### implementation
138 config = mkIf cfg.enable {
139 systemd.services.xinetd = {
140 description = "xinetd server";
141 after = [ "network.target" ];
142 wantedBy = [ "multi-user.target" ];
143 path = [ pkgs.xinetd ];
144 script = "exec xinetd -syslog daemon -dontfork -stayalive -f ${configFile}";