Skip to content

Commit

Permalink
Merge pull request #551 from cachix/nginx
Browse files Browse the repository at this point in the history
add nginx service
  • Loading branch information
domenkozar authored Apr 24, 2023
2 parents dc1c08f + 3139f8a commit ce53645
Showing 1 changed file with 64 additions and 0 deletions.
64 changes: 64 additions & 0 deletions src/modules/services/nginx.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
{ pkgs, lib, config, ... }:

let
cfg = config.services.nginx;
configFile = pkgs.writeText "nginx.conf" ''
pid ${config.env.DEVENV_STATE}/nginx/nginx.pid;
error_log stderr debug;
daemon off;
events {
${cfg.eventsConfig}
}
http {
access_log off;
client_body_temp_path ${config.env.DEVENV_STATE}/nginx/;
proxy_temp_path ${config.env.DEVENV_STATE}/nginx/;
fastcgi_temp_path ${config.env.DEVENV_STATE}/nginx/;
scgi_temp_path ${config.env.DEVENV_STATE}/nginx/;
uwsgi_temp_path ${config.env.DEVENV_STATE}/nginx/;
${cfg.httpConfig}
}
'';
in
{
options.services.nginx = {
enable = lib.mkEnableOption "nginx";

package = lib.mkOption {
type = lib.types.package;
default = pkgs.nginx;
defaultText = "pkgs.nginx";
description = "The nginx package to use.";
};

httpConfig = lib.mkOption {
type = lib.types.lines;
default = "";
description = "The nginx configuration.";
};

eventsConfig = lib.mkOption {
type = lib.types.lines;
default = "";
description = "The nginx events configuration.";
};

configFile = lib.mkOption {
type = lib.types.path;
default = configFile;
internal = true;
description = "The nginx configuration file.";
};
};

config = lib.mkIf cfg.enable {
processes.nginx.exec = "${cfg.package}/bin/nginx -c ${cfg.configFile} -e /dev/stderr";

enterShell = ''
mkdir -p ${config.env.DEVENV_STATE}/nginx
'';
};
}

0 comments on commit ce53645

Please sign in to comment.