summaryrefslogtreecommitdiff
path: root/hostnix/elmo/cal.nix
blob: 64950a45919c847197c95847733d2dc0b04ea0ff (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
{ pkgs, ... }:

{
  systemd.tmpfiles.rules = [
    "d /opt/cal 0755 joe users"
  ];

  # TODO socket activation
  systemd.services.cal = {
    # Deno writes its module cache under $HOME, which DynamicUser does not give
    # us; point it at /var/cache/cal instead.
    # TODO node
    environment.DENO_DIR = "/var/cache/cal";
    serviceConfig = {
      Type = "exec";
      DynamicUser = true;
      WorkingDirectory = "/opt/cal";
      StateDirectory = "cal";
      CacheDirectory = "cal";
      ExecStart = "${pkgs.deno}/bin/deno run --allow-net --allow-read --allow-write=/opt/cal/web/events,/opt/cal/web/_site web/server.ts";
    };
  };

  # TODO allocate domain?
  services.nginx.virtualHosts."cal.elmo.mou.fo" = {
    useACMEHost = "elmo.mou.fo";
    forceSSL = true;
    locations."/" = {
      proxyPass = "http://127.0.0.1:8000";
    };
  };
}