Skip to content

Commit

Permalink
fix(nginx): link nginx.conf to dataDir (#173)
Browse files Browse the repository at this point in the history
  • Loading branch information
szucsitg authored and shivaraj-bh committed May 9, 2024
1 parent c93d0ad commit 75a42b9
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 14 deletions.
3 changes: 2 additions & 1 deletion nix/nginx/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
51 changes: 38 additions & 13 deletions nix/nginx/nginx_test.nix
Original file line number Diff line number Diff line change
@@ -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"; };
}

0 comments on commit 75a42b9

Please sign in to comment.