{ 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 = "d09927ca6f7af2404e9c3a09a6e99dfdd1e87577"; }; in { after = ["network.target"]; wantedBy = ["multi-user.target"]; script = "${lib.getExe python} -m gunicorn -w 5 --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 } ''; }; }