summary refs log tree commit diff
path: root/hosts/vps/services/arXiv.nix
blob: d53d8057c19748d357844437861f3c54f6cd9c3d (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
{
  pkgs,
  config,
  lib,
  ...
}: {
  systemd.services.arXiv-randomizer = let
    python = pkgs.python3.withPackages (ps:
      with ps; [
        beautifulsoup4
        dateutil
        numpy
        flask
        feedparser
        gunicorn
      ]);
    arXiv-randomizer = builtins.fetchGit {
      url = "https://git.tzlil.net/arXiv.git";
      ref = "master";
      rev = "fe2d2f0dcc7ae16906a318bf96a651f135649ae7";
    };
  in {
    after = ["network.target"];
    wantedBy = ["multi-user.target"];
    script = "${lib.getExe python} -m gunicorn -w 1 --log-level debug -b 0.0.0.0:3000 --timeout 90 app:app";
    serviceConfig = {
      Restart = "on-failure";
      RestartSec = 0;
      WorkingDirectory = "${arXiv-randomizer}";
    };
  };

  services.caddy = {
    virtualHosts."tzlil.net".extraConfig = ''
      redir /arXiv /arXiv/
      handle_path /arXiv/* {
        reverse_proxy :3000
      }
    '';
  };
}