summary refs log tree commit diff
path: root/machines/renard/default.nix
blob: 2be8e72fb7eaf9b43f929c21cd931775f8206bc4 (plain)
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
{ me, machines, ... }:

{
  imports = [
    ../../modules/common.nix

    ./hardware.nix
    ./devices.nix

    ../../modules/binary-cache.nix
    ../../modules/git.nix
    ../../modules/syncthing.nix

    ../../services/cgit.nix
    ../../services/minecraft.nix
    ../../services/miniflux.nix
    ../../services/shiori.nix
    ../../services/matrix.nix
    ../../services/goatcounter.nix
    ../../services/irc
  ];

  foundation = {
    www = {
      enable = true;

      public = true;
      tailnet = true;
    };

    monitoring = {
      server = {
        enable = true;
        hosts = map (m: {
          inherit (m) name;
          inherit (m.tailscale) ip;
        }) machines;
      };

      services = [
        "base"
        "tailnet"
        "cache"
        "git"
        "mel"
        "shorest"
        "matrix"
        "goat"
      ];
    };
  };

  services.nginx.virtualHosts = {
    base.locations = {
      "/stuff/" = {
        alias = "/var/www/html/";
      };

      # redirect to akkoma on lapin
      "/.well-known/webfinger" = {
        return = "301 https://soc.rnrd.eu$request_uri";
      };

      # delegate matrix to subdomain `matrix.rnrd.eu`
      "/.well-known/matrix/server" = {
        return = "200 '{ \"m.server\": \"matrix.rnrd.eu:443\" }'";
        extraConfig = ''
          default_type application/json;
        '';
      };
      "/.well-known/matrix/client" = {
        return = ''
          200 '{
            "m.homeserver": {
              "base_url": "https://matrix.rnrd.eu/"
            },
            "org.matrix.msc3575.proxy": {
              "url": "https://matrix.rnrd.eu/"
            }
          }'
        '';
        extraConfig = ''
          default_type application/json;
          add_header "Access-Control-Allow-Origin" *;
        '';
      };
    };

    "sho.rest" = {
      enableACME = true;
      forceSSL = true;
      locations."/" = {
        proxyPass = "http://127.0.0.1:5000";
      };
      extraConfig = ''
        access_log /var/log/nginx/shorest.access.log json_combined;
      '';
    };

    "mel.gg" = {
      enableACME = true;
      forceSSL = true;
      root = "/srv/mel";
      extraConfig = ''
        access_log /var/log/nginx/mel.access.log json_combined;
      '';
    };

    "catskill.dev" = {
      enableACME = true;
      forceSSL = true;
      root = "/srv/catskill";
      extraConfig = ''
        access_log /var/log/nginx/catskill.access.log json_combined;
      '';
    };

    "moth.run" = {
      enableACME = true;
      forceSSL = true;
      root = "/srv/moth";
      extraConfig = ''
        access_log /var/log/nginx/moth.access.log json_combined;
      '';
    };
  };

  system.stateVersion = "24.05";
}