summary refs log tree commit diff
path: root/machines/renard/default.nix
blob: 01883409665c326af21bd416f3c689799e509ae9 (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
{ me, machines, ... }:

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

    ./hardware.nix
    ./devices.nix

    ../../modules/www
    ../../modules/git.nix
    ../../modules/syncthing.nix

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

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

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

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

      # delegate matrix to lapin
      "/.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;
      '';
    };
  };

  system.stateVersion = "24.05";
}