diff options
author | Vincent Ambo <tazjin@google.com> | 2020-02-08T14·06+0000 |
---|---|---|
committer | Vincent Ambo <tazjin@google.com> | 2020-02-08T14·06+0000 |
commit | 7935957938fb4bd73b557e42fa828b1470979777 (patch) | |
tree | e7289865c0b38851172a292897e8dd897a2ae672 /web/homepage/nginx.nix | |
parent | 8e9fb739582b5ed871522826ea145f4a9dac2777 (diff) |
refactor(web): Move nginx setup to //web/homepage r/487
The homepage is going to be the landing page for all content, whether it be blog posts or other stuff.
Diffstat (limited to '')
-rw-r--r-- | web/homepage/nginx.nix (renamed from web/blog/nginx.nix) | 36 |
1 files changed, 21 insertions, 15 deletions
diff --git a/web/blog/nginx.nix b/web/homepage/nginx.nix index 7c600c38c0..90a13a1e98 100644 --- a/web/blog/nginx.nix +++ b/web/homepage/nginx.nix @@ -1,24 +1,30 @@ # This file creates an nginx server that serves the blog on port 8080. # # It's not intended to be the user-facing nginx. -{ pkgs, lib, posts, renderedBlog, ... }: +{ + # third_party attributes supplied by callPackage + writeText, writeShellScriptBin, nginx, lib, + + # website content + blog +}: let inherit (builtins) hasAttr filter map; - inherit (pkgs.third_party) writeText writeShellScriptBin nginx; + inherit (pkgs.third_party) ; oldRedirects = lib.concatStringsSep "\n" (map (post: '' location ~* ^(en)?/${post.oldKey} { # TODO(tazjin): 301 once this works return 302 /${post.key}; } - '') (filter (hasAttr "oldKey") posts)); + '') (filter (hasAttr "oldKey") blog.posts)); - config = writeText "blog-nginx.conf" '' + config = writeText "homepage-nginx.conf" '' daemon off; worker_processes 1; error_log stderr; - pid /tmp/nginx-tazblog.pid; + pid /tmp/nginx-homepage.pid; events { worker_connections 1024; @@ -26,11 +32,11 @@ let http { include ${nginx}/conf/mime.types; - fastcgi_temp_path /tmp/nginx-tazblog; - uwsgi_temp_path /tmp/nginx-tazblog; - scgi_temp_path /tmp/nginx-tazblog; - client_body_temp_path /tmp/nginx-tazblog; - proxy_temp_path /tmp/nginx-tazblog; + fastcgi_temp_path /tmp/nginx-homepage; + uwsgi_temp_path /tmp/nginx-homepage; + scgi_temp_path /tmp/nginx-homepage; + client_body_temp_path /tmp/nginx-homepage; + proxy_temp_path /tmp/nginx-homepage; sendfile on; # Logging is handled by the primary nginx server @@ -38,10 +44,10 @@ let server { listen 8080 default_server; - root ${renderedBlog}; + root ${blog.rendered}; location /static { - alias ${./static}/; + alias ${blog.static}/; } ${oldRedirects} @@ -56,13 +62,13 @@ let } } ''; -in writeShellScriptBin "tazblog" '' +in writeShellScriptBin "homepage" '' if [[ -v CONTAINER_SETUP ]]; then cd /run echo 'nogroup:x:30000:nobody' >> /etc/group echo 'nobody:x:30000:30000:nobody:/tmp:/bin/bash' >> /etc/passwd fi - mkdir -p /tmp/nginx-tazblog - exec ${pkgs.third_party.nginx}/bin/nginx -c ${config} + mkdir -p /tmp/nginx-homepage + exec ${nginx}/bin/nginx -c ${config} '' |