Merge pull request #141 from orbitz/fix-nginx-required-config

Fix nginx required config
This commit is contained in:
Domen Kožar 2013-04-14 02:28:23 -07:00
commit 25cd3579cb

View file

@ -1,14 +1,16 @@
{ config, pkgs, ... }: { config, pkgs, ... }:
with pkgs.lib; with pkgs.lib;
let let
cfg = config.services.nginx; cfg = config.services.nginx;
configFile = pkgs.writeText "nginx.conf" '' configFile = pkgs.writeText "nginx.conf" ''
user nginx nginx;
daemon off;
${cfg.config} ${cfg.config}
''; '';
in in
{ {
options = { options = {
services.nginx = { services.nginx = {
@ -18,9 +20,9 @@ in
Enable the nginx Web Server. Enable the nginx Web Server.
"; ";
}; };
config = mkOption { config = mkOption {
default = ""; default = "events {}";
description = " description = "
Verbatim nginx.conf configuration. Verbatim nginx.conf configuration.
"; ";
@ -33,14 +35,14 @@ in
"; ";
}; };
}; };
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
environment.systemPackages = [ pkgs.nginx ]; environment.systemPackages = [ pkgs.nginx ];
# TODO: test user supplied config file pases syntax test # TODO: test user supplied config file pases syntax test
systemd.services.nginx = { systemd.services.nginx = {
description = "Nginx Web Server"; description = "Nginx Web Server";
after = [ "network.target" ]; after = [ "network.target" ];
@ -55,11 +57,11 @@ in
ExecStart = "${pkgs.nginx}/bin/nginx -c ${configFile} -p ${cfg.stateDir}"; ExecStart = "${pkgs.nginx}/bin/nginx -c ${configFile} -p ${cfg.stateDir}";
}; };
}; };
users.extraUsers.nginx = { users.extraUsers.nginx = {
group = "nginx"; group = "nginx";
}; };
users.extraGroups.nginx = {}; users.extraGroups.nginx = {};
}; };
} }