summary refs log tree commit diff
path: root/hosts/vps/services
diff options
context:
space:
mode:
Diffstat (limited to 'hosts/vps/services')
-rw-r--r--hosts/vps/services/arXiv.nix41
-rw-r--r--hosts/vps/services/website.nix1
2 files changed, 42 insertions, 0 deletions
diff --git a/hosts/vps/services/arXiv.nix b/hosts/vps/services/arXiv.nix
new file mode 100644
index 0000000..4e45a11
--- /dev/null
+++ b/hosts/vps/services/arXiv.nix
@@ -0,0 +1,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 = "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
+      }
+    '';
+  };
+}
diff --git a/hosts/vps/services/website.nix b/hosts/vps/services/website.nix
index 8f15df1..f3ef7b8 100644
--- a/hosts/vps/services/website.nix
+++ b/hosts/vps/services/website.nix
@@ -52,6 +52,7 @@
              <pre>
             <a href="https://fm.tzlil.net">fm.tzlil.net</a> music
             <a href="https://git.tzlil.net">git.tzlil.net</a> for everything im too embarrased to put on sourcehut
+            <a href="/arXiv">arXiv randomizer</a>
             </pre>
           ''} /
             file_server