dragnpkgs/lib/dev-nginx/default.nix

47 lines
982 B
Nix

{
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}
''