fix(nginx): link nginx.conf to dataDir (#173)

This commit is contained in:
Adam Szucs-Matyas 2024-05-07 10:36:16 +02:00 committed by Shivaraj B H
parent c93d0ad98f
commit 75a42b9e9e
2 changed files with 40 additions and 14 deletions

View File

@ -100,7 +100,8 @@ in
if [[ ! -d "${config.dataDir}" ]]; then
mkdir -p "${config.dataDir}"
fi
nginx -p "$(pwd)" -c ${config.configFile} -e /dev/stderr
ln -sfn ${config.configFile} "${config.dataDir}/nginx.conf"
nginx -p "$(pwd)" -c "${config.dataDir}/nginx.conf" -e /dev/stderr
'';
};
in

View File

@ -1,18 +1,43 @@
{ pkgs, config, ... }: {
services.nginx."nginx1".enable = true;
services.nginx."nginx1" = {
enable = true;
httpConfig = ''
server {
listen 8888;
include ../../importedconfig.conf;
}
'';
};
settings.processes.test =
let
cfg = config.services.nginx."nginx1";
in
settings.processes =
{
command = pkgs.writeShellApplication {
runtimeInputs = [ cfg.package pkgs.gnugrep pkgs.curl ];
text = ''
curl http://127.0.0.1:${builtins.toString cfg.port} | grep -q "nginx"
'';
name = "nginx-test";
init = {
command = pkgs.writeShellApplication {
runtimeInputs = [ pkgs.coreutils ];
text = ''
cat >importedconfig.conf <<EOL
location / {
add_header Content-Type text/plain;
return 200 'Looks good';
}
EOL
'';
name = "init";
};
};
depends_on."nginx1".condition = "process_healthy";
};
test =
let
cfg = config.services.nginx."nginx1";
in
{
command = pkgs.writeShellApplication {
runtimeInputs = [ cfg.package pkgs.gnugrep pkgs.curl ];
text = ''
curl -s -H "Accept: text/plain" http://127.0.0.1:8888 | grep -q "Looks good"
'';
name = "nginx-test";
};
depends_on."nginx1".condition = "process_healthy";
};
} // { "nginx1".depends_on."init".condition = "process_completed"; };
}