summaryrefslogtreecommitdiff
path: root/Biz/PodcastItLater/Web.nix
diff options
context:
space:
mode:
authorBen Sima <ben@bsima.me>2025-08-13 13:36:30 -0400
committerBen Sima <ben@bsima.me>2025-08-28 12:14:09 -0400
commit0b005c192b2c141c7f6c9bff4a0702361814c21d (patch)
tree3527a76137f6ee4dd970bba17a93617a311149cb /Biz/PodcastItLater/Web.nix
parent7de0a3e0abbf1e152423e148d507e17b752a4982 (diff)
Prototype PodcastItLater
This implements a working prototype of PodcastItLater. It basically just works for a single user currently, but the articles are nice to listen to and this is something that we can start to build with.
Diffstat (limited to 'Biz/PodcastItLater/Web.nix')
-rw-r--r--Biz/PodcastItLater/Web.nix91
1 files changed, 91 insertions, 0 deletions
diff --git a/Biz/PodcastItLater/Web.nix b/Biz/PodcastItLater/Web.nix
new file mode 100644
index 0000000..692d39e
--- /dev/null
+++ b/Biz/PodcastItLater/Web.nix
@@ -0,0 +1,91 @@
+{
+ options,
+ lib,
+ config,
+ ...
+}: let
+ cfg = config.services.podcastitlater-web;
+ rootDomain = "bensima.com";
+ ports = import ../../Omni/Cloud/Ports.nix;
+in {
+ options.services.podcastitlater-web = {
+ enable = lib.mkEnableOption "Enable the PodcastItLater web service";
+ port = lib.mkOption {
+ type = lib.types.int;
+ default = 8000;
+ description = ''
+ The port on which PodcastItLater web will listen for
+ incoming HTTP traffic.
+ '';
+ };
+ dataDir = lib.mkOption {
+ type = lib.types.path;
+ default = "/var/podcastitlater";
+ description = "Data directory for PodcastItLater (shared with worker)";
+ };
+ package = lib.mkOption {
+ type = lib.types.package;
+ description = "PodcastItLater web package to use";
+ };
+ };
+ config = lib.mkIf cfg.enable {
+ systemd.services.podcastitlater-web = {
+ path = [cfg.package];
+ wantedBy = ["multi-user.target"];
+ preStart = ''
+ # Create data directory if it doesn't exist
+ mkdir -p ${cfg.dataDir}
+
+ # Manual step: create this file with secrets
+ # MAILGUN_WEBHOOK_KEY=your-mailgun-webhook-key
+ # SECRET_KEY=your-secret-key-for-sessions
+ # SESSION_SECRET=your-session-secret
+ # EMAIL_FROM=noreply@podcastitlater.bensima.com
+ # SMTP_SERVER=smtp.mailgun.org
+ # SMTP_PASSWORD=your-smtp-password
+ test -f /run/podcastitlater/env
+ '';
+ script = ''
+ ${cfg.package}/bin/podcastitlater-web
+ '';
+ description = ''
+ PodcastItLater Web Service
+ '';
+ serviceConfig = {
+ Environment = [
+ "PORT=${toString cfg.port}"
+ "AREA=Live"
+ "DATABASE_PATH=${cfg.dataDir}/podcast.db"
+ "BASE_URL=https://podcastitlater.${rootDomain}"
+ ];
+ EnvironmentFile = "/run/podcastitlater/env";
+ KillSignal = "INT";
+ Type = "simple";
+ Restart = "on-abort";
+ RestartSec = "1";
+ };
+ };
+
+ # Nginx configuration
+ services.nginx = {
+ enable = true;
+ recommendedGzipSettings = true;
+ recommendedOptimisation = true;
+ recommendedProxySettings = true;
+ recommendedTlsSettings = true;
+ statusPage = true;
+
+ virtualHosts."podcastitlater.${rootDomain}" = {
+ forceSSL = true;
+ enableACME = true;
+ locations."/" = {
+ proxyPass = "http://localhost:${toString cfg.port}";
+ proxyWebsockets = true;
+ };
+ };
+ };
+
+ # Ensure firewall allows web traffic
+ networking.firewall.allowedTCPPorts = [ports.ssh ports.http ports.https];
+ };
+}