mirror of
https://github.com/ilyakooo0/nixpkgs.git
synced 2024-12-27 13:57:10 +03:00
add most basic nginx service
This commit is contained in:
parent
d99fce2631
commit
854a37aa7e
@ -179,6 +179,7 @@
|
|||||||
./services/ttys/agetty.nix
|
./services/ttys/agetty.nix
|
||||||
./services/web-servers/apache-httpd/default.nix
|
./services/web-servers/apache-httpd/default.nix
|
||||||
./services/web-servers/jboss/default.nix
|
./services/web-servers/jboss/default.nix
|
||||||
|
./services/web-servers/nginx/default.nix
|
||||||
./services/web-servers/tomcat.nix
|
./services/web-servers/tomcat.nix
|
||||||
./services/x11/desktop-managers/default.nix
|
./services/x11/desktop-managers/default.nix
|
||||||
./services/x11/display-managers/auto.nix
|
./services/x11/display-managers/auto.nix
|
||||||
|
65
modules/services/web-servers/nginx/default.nix
Normal file
65
modules/services/web-servers/nginx/default.nix
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
{ config, pkgs, ... }:
|
||||||
|
|
||||||
|
with pkgs.lib;
|
||||||
|
|
||||||
|
let
|
||||||
|
cfg = config.services.nginx;
|
||||||
|
configFile = pkgs.writeText "nginx.conf" ''
|
||||||
|
${cfg.config}
|
||||||
|
'';
|
||||||
|
in
|
||||||
|
|
||||||
|
{
|
||||||
|
options = {
|
||||||
|
services.nginx = {
|
||||||
|
enable = mkOption {
|
||||||
|
default = false;
|
||||||
|
description = "
|
||||||
|
Enable the nginx Web Server.
|
||||||
|
";
|
||||||
|
};
|
||||||
|
|
||||||
|
config = mkOption {
|
||||||
|
default = "";
|
||||||
|
description = "
|
||||||
|
Verbatim nginx.conf configuration.
|
||||||
|
";
|
||||||
|
};
|
||||||
|
|
||||||
|
stateDir = mkOption {
|
||||||
|
default = "/var/spool/nginx";
|
||||||
|
description = "
|
||||||
|
Directory holding all state for nginx to run.
|
||||||
|
";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
config = mkIf cfg.enable {
|
||||||
|
environment.systemPackages = [ pkgs.nginx ];
|
||||||
|
|
||||||
|
# TODO: test user supplied config file pases syntax test
|
||||||
|
|
||||||
|
systemd.services.nginx = {
|
||||||
|
description = "Nginx Web Server";
|
||||||
|
after = [ "network.target" ];
|
||||||
|
wantedBy = [ "multi-user.target" ];
|
||||||
|
path = [ pkgs.nginx ];
|
||||||
|
preStart =
|
||||||
|
''
|
||||||
|
mkdir -p ${cfg.stateDir}/logs
|
||||||
|
chown -R nginx:nginx ${cfg.stateDir}
|
||||||
|
'';
|
||||||
|
serviceConfig = {
|
||||||
|
ExecStart = "${pkgs.nginx}/bin/nginx -c ${configFile} -p ${cfg.stateDir}";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
users.extraUsers.nginx = {
|
||||||
|
group = "nginx";
|
||||||
|
};
|
||||||
|
|
||||||
|
users.extraGroups.nginx = {};
|
||||||
|
};
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user