1 { config, lib, pkgs, ... }:
6 cfg = config.services.fcgiwrap;
14 description = lib.mdDoc "Whether to enable fcgiwrap, a server for running CGI applications over FastCGI.";
17 preforkProcesses = mkOption {
20 description = lib.mdDoc "Number of processes to prefork.";
23 socketType = mkOption {
24 type = types.enum [ "unix" "tcp" "tcp6" ];
26 description = lib.mdDoc "Socket type: 'unix', 'tcp' or 'tcp6'.";
29 socketAddress = mkOption {
31 default = "/run/fcgiwrap.sock";
32 example = "1.2.3.4:5678";
33 description = lib.mdDoc "Socket address. In case of a UNIX socket, this should be its filesystem path.";
37 type = types.nullOr types.str;
39 description = lib.mdDoc "User permissions for the socket.";
43 type = types.nullOr types.str;
45 description = lib.mdDoc "Group permissions for the socket.";
50 config = mkIf cfg.enable {
51 systemd.services.fcgiwrap = {
52 after = [ "nss-user-lookup.target" ];
53 wantedBy = optional (cfg.socketType != "unix") "multi-user.target";
56 ExecStart = "${pkgs.fcgiwrap}/sbin/fcgiwrap -c ${builtins.toString cfg.preforkProcesses} ${
57 optionalString (cfg.socketType != "unix") "-s ${cfg.socketType}:${cfg.socketAddress}"
59 } // (if cfg.user != null && cfg.group != null then {
65 systemd.sockets = if (cfg.socketType == "unix") then {
67 wantedBy = [ "sockets.target" ];
68 socketConfig.ListenStream = cfg.socketAddress;