diff --git a/modules/services/web-servers/nginx/default.nix b/modules/services/web-servers/nginx/default.nix index c9c242400f7..03f37d3518e 100644 --- a/modules/services/web-servers/nginx/default.nix +++ b/modules/services/web-servers/nginx/default.nix @@ -4,8 +4,9 @@ with pkgs.lib; let cfg = config.services.nginx; + nginx = pkgs.nginx.override { fullWebDAV = cfg.fullWebDAV; }; configFile = pkgs.writeText "nginx.conf" '' - user nginx nginx; + user ${cfg.user} ${cfg.group}; daemon off; ${cfg.config} ''; @@ -34,12 +35,27 @@ in Directory holding all state for nginx to run. "; }; + + user = mkOption { + default = "nginx"; + description = "User account under which nginx runs."; + }; + + group = mkOption { + default = "nginx"; + description = "Group account under which nginx runs."; + }; + + fullWebDAV = mkOption { + default = false; + description = "Compile in a third party module providing full WebDAV support"; + }; }; }; config = mkIf cfg.enable { - environment.systemPackages = [ pkgs.nginx ]; + environment.systemPackages = [ nginx ]; # TODO: test user supplied config file pases syntax test @@ -47,14 +63,14 @@ in description = "Nginx Web Server"; after = [ "network.target" ]; wantedBy = [ "multi-user.target" ]; - path = [ pkgs.nginx ]; + path = [ nginx ]; preStart = '' mkdir -p ${cfg.stateDir}/logs - chown -R nginx:nginx ${cfg.stateDir} + chown -R ${cfg.user}:${cfg.group} ${cfg.stateDir} ''; serviceConfig = { - ExecStart = "${pkgs.nginx}/bin/nginx -c ${configFile} -p ${cfg.stateDir}"; + ExecStart = "${nginx}/bin/nginx -c ${configFile} -p ${cfg.stateDir}"; }; };