Add options for user and group to run nginx as.

Add option to compile in full WebDAV support.
This commit is contained in:
Russell O'Connor 2013-05-05 15:44:06 -04:00
parent 6c988a593a
commit 7c8c1dade5

View File

@ -4,8 +4,9 @@ with pkgs.lib;
let let
cfg = config.services.nginx; cfg = config.services.nginx;
nginx = pkgs.nginx.override { fullWebDAV = cfg.fullWebDAV; };
configFile = pkgs.writeText "nginx.conf" '' configFile = pkgs.writeText "nginx.conf" ''
user nginx nginx; user ${cfg.user} ${cfg.group};
daemon off; daemon off;
${cfg.config} ${cfg.config}
''; '';
@ -34,12 +35,27 @@ in
Directory holding all state for nginx to run. 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 { config = mkIf cfg.enable {
environment.systemPackages = [ pkgs.nginx ]; environment.systemPackages = [ nginx ];
# TODO: test user supplied config file pases syntax test # TODO: test user supplied config file pases syntax test
@ -47,14 +63,14 @@ in
description = "Nginx Web Server"; description = "Nginx Web Server";
after = [ "network.target" ]; after = [ "network.target" ];
wantedBy = [ "multi-user.target" ]; wantedBy = [ "multi-user.target" ];
path = [ pkgs.nginx ]; path = [ nginx ];
preStart = preStart =
'' ''
mkdir -p ${cfg.stateDir}/logs mkdir -p ${cfg.stateDir}/logs
chown -R nginx:nginx ${cfg.stateDir} chown -R ${cfg.user}:${cfg.group} ${cfg.stateDir}
''; '';
serviceConfig = { serviceConfig = {
ExecStart = "${pkgs.nginx}/bin/nginx -c ${configFile} -p ${cfg.stateDir}"; ExecStart = "${nginx}/bin/nginx -c ${configFile} -p ${cfg.stateDir}";
}; };
}; };