about summary refs log tree commit diff
path: root/users/tazjin/nixos/modules/homepage.nix
blob: 65191d6e708748d46077c8c29c941d637dfcce63 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# serve tazjin's website & blog
{ depot, config, lib, pkgs, ... }:

let
  extraConfig = ''
    location = /en/rss.xml {
      return 301 https://tazj.in/feed.atom;
    }

    ${depot.users.tazjin.blog.oldRedirects}
    location /blog/ {
      alias ${depot.users.tazjin.blog.rendered}/;

      if ($request_uri ~ ^/(.*)\.html$) {
        return 302 /$1;
      }

      try_files $uri $uri.html $uri/ =404;
    }

    location = /predlozhnik {
      return 302 https://predlozhnik.ru;
    }

    # redirect for easier entry on a TV
    location = /tv {
      return 302 https://tazj.in/blobs/play.html;
    }

    # Temporary place for serving static files.
    location /blobs/ {
      alias /var/lib/tazjins-blobs/;
    }
  '';
in
{
  config = {
    services.nginx.virtualHosts."tazj.in" = {
      enableACME = true;
      forceSSL = true;
      root = depot.users.tazjin.homepage;
      serverAliases = [ "www.tazj.in" ];
      inherit extraConfig;
    };

    services.nginx.virtualHosts."y.tazj.in" = {
      enableSSL = true;
      useACMEHost = "y.tazj.in";
      root = depot.users.tazjin.homepage;
      inherit extraConfig;
    };

    services.nginx.virtualHosts."git.tazj.in" = {
      enableACME = true;
      forceSSL = true;
      extraConfig = "return 301 https://code.tvl.fyi$request_uri;";
    };
  };
}