{ 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 } ''; }; }