add mkNginxServer

This commit is contained in:
xenia 2024-04-23 18:32:43 -04:00
parent b277d43f77
commit 69d374a24f
2 changed files with 48 additions and 0 deletions

View File

@ -23,6 +23,8 @@
# add to top level because it has a binary
feedvalidator = final.python312Packages.feedvalidator;
mkNginxServer = prev.callPackage ./lib/dev-nginx {};
})
];
}

46
lib/dev-nginx/default.nix Normal file
View File

@ -0,0 +1,46 @@
{
writeText,
writeShellScriptBin,
nginx,
systemd
}:
{ siteConfig }:
let conf = writeText "nginx.conf" ''
daemon off;
events {}
pid /tmp/nginx.pid;
http {
access_log /dev/stdout;
client_body_temp_path /tmp;
proxy_temp_path /tmp;
fastcgi_temp_path /tmp;
uwsgi_temp_path /tmp;
scgi_temp_path /tmp;
include ${nginx}/conf/mime.types;
default_type application/octet-stream;
sendfile on;
types_hash_max_size 4096;
types_hash_bucket_size 128;
server {
server_name localhost;
listen 127.0.0.1:8080;
gzip on;
gzip_min_length 256;
gzip_proxied expired no-cache no-store private auth;
gzip_types text/plain application/xml image/svg+xml text/css text/javascript;
${siteConfig}
}
}
'';
in
writeShellScriptBin "dev-nginx.sh" ''
exec ${systemd}/bin/systemd-run --user -t -pPrivateTmp=true --working-directory="$PWD" ${nginx}/bin/nginx -p "$PWD" -e stderr -c ${conf}
''