about summary refs log tree commit diff
path: root/web/blog
diff options
context:
space:
mode:
authorVincent Ambo <tazjin@google.com>2020-02-08T14·06+0000
committerVincent Ambo <tazjin@google.com>2020-02-08T14·06+0000
commit7935957938fb4bd73b557e42fa828b1470979777 (patch)
treee7289865c0b38851172a292897e8dd897a2ae672 /web/blog
parent8e9fb739582b5ed871522826ea145f4a9dac2777 (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 'web/blog')
-rw-r--r--web/blog/default.nix9
-rw-r--r--web/blog/nginx.nix68
2 files changed, 5 insertions, 72 deletions
diff --git a/web/blog/default.nix b/web/blog/default.nix
index 1bc026bf2a..4fa97f2248 100644
--- a/web/blog/default.nix
+++ b/web/blog/default.nix
@@ -31,7 +31,7 @@ let
   posts = list post (import ./posts.nix);
   fragments = import ./fragments.nix args;
 
-  renderedBlog = pkgs.third_party.runCommandNoCC "tazjins-blog" {} ''
+  rendered = pkgs.third_party.runCommandNoCC "tazjins-blog" {} ''
     mkdir -p $out
 
     cp ${fragments.blogIndex posts} $out/index.html
@@ -40,6 +40,7 @@ let
       "cp ${fragments.renderPost post} $out/${post.key}.html"
     ) posts)}
   '';
-in import ./nginx.nix (args // {
-  inherit posts renderedBlog;
-})
+in {
+  inherit post posts rendered;
+  static = ./static;
+}
diff --git a/web/blog/nginx.nix b/web/blog/nginx.nix
deleted file mode 100644
index 7c600c38c0..0000000000
--- a/web/blog/nginx.nix
+++ /dev/null
@@ -1,68 +0,0 @@
-# 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, ... }:
-
-let
-  inherit (builtins) hasAttr filter map;
-  inherit (pkgs.third_party) writeText writeShellScriptBin nginx;
-
-  oldRedirects = lib.concatStringsSep "\n" (map (post: ''
-    location ~* ^(en)?/${post.oldKey} {
-      # TODO(tazjin): 301 once this works
-      return 302 /${post.key};
-    }
-  '') (filter (hasAttr "oldKey") posts));
-
-  config = writeText "blog-nginx.conf" ''
-    daemon off;
-    worker_processes 1;
-    error_log stderr;
-    pid /tmp/nginx-tazblog.pid;
-
-    events {
-      worker_connections  1024;
-    }
-
-    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;
-      sendfile on;
-
-      # Logging is handled by the primary nginx server
-      access_log off;
-
-      server {
-        listen 8080 default_server;
-        root ${renderedBlog};
-
-        location /static {
-          alias ${./static}/;
-        }
-
-        ${oldRedirects}
-
-        location / {
-          if ($request_uri ~ ^/(.*)\.html$) {
-            return 302 /$1;
-          }
-
-          try_files $uri $uri.html $uri/ =404;
-        }
-      }
-    }
-  '';
-in writeShellScriptBin "tazblog" ''
-  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}
-''