diff options
| author | Joe Mou <dev@mou.fo> | 2026-08-10 14:51:17 -0400 |
|---|---|---|
| committer | Joe Mou <dev@mou.fo> | 2026-08-11 07:17:05 -0400 |
| commit | 1373c71a4abb5935f758bf54c89d69f762c96a17 (patch) | |
| tree | 280a42dfbf6954d076f54f3a1d25cf613babcfaf /hostnix | |
| parent | 8fafbf0d920dd00ac764bcb5227ed7f910b71558 (diff) | |
Clippersnip
Diffstat (limited to 'hostnix')
| -rw-r--r-- | hostnix/elmo/clippersnip.nix | 64 | ||||
| -rw-r--r-- | hostnix/elmo/configuration.nix | 1 |
2 files changed, 65 insertions, 0 deletions
diff --git a/hostnix/elmo/clippersnip.nix b/hostnix/elmo/clippersnip.nix new file mode 100644 index 0000000..93c1011 --- /dev/null +++ b/hostnix/elmo/clippersnip.nix @@ -0,0 +1,64 @@ +{ pkgs, ... }: + +{ + systemd.tmpfiles.rules = [ + "d /opt/clippersnip 0755 joe users" + "e /var/lib/private/clippersnip - - - 365d" + ]; + + systemd.sockets.clippersnip = { + wantedBy = [ "sockets.target" ]; + socketConfig = { + ListenStream = "/run/clippersnip/socket"; + SocketGroup = "nginx"; + SocketMode = "0660"; + }; + }; + + systemd.services.clippersnip = { + requires = [ "clippersnip.socket" ]; + after = [ "clippersnip.socket" ]; + path = [ pkgs.ffmpeg-headless ]; + environment.CLIPS_DIR = "/var/lib/clippersnip"; + serviceConfig = { + Type = "exec"; + DynamicUser = true; + WorkingDirectory = "/opt/clippersnip"; + StateDirectory = "clippersnip"; + ExecStart = "${pkgs.nodejs-slim_24}/bin/node server.ts"; + }; + }; + + # TODO allocate domain? + services.nginx.virtualHosts."cs.elmo.mou.fo" = { + useACMEHost = "elmo.mou.fo"; + forceSSL = true; + locations."/" = { + proxyPass = "http://unix:/run/clippersnip/socket"; + }; + locations."/c/" = { + proxyPass = "http://unix:/run/clippersnip/socket"; + extraConfig = '' + auth_request off; + proxy_buffering off; + ''; + }; + # ffmpeg can run for minutes. + locations."/api/clip" = { + proxyPass = "http://unix:/run/clippersnip/socket"; + extraConfig = '' + proxy_read_timeout 600s; + ''; + }; + # Serve audio HTTP Range requests directly. + locations."/api/audio" = { + proxyPass = "http://unix:/run/clippersnip/socket"; + extraConfig = '' + proxy_buffering off; + proxy_read_timeout 300s; + ''; + }; + }; + + services.oauth2-proxy.nginx.virtualHosts."cs.elmo.mou.fo" = { }; +} diff --git a/hostnix/elmo/configuration.nix b/hostnix/elmo/configuration.nix index ad44fa2..5431e30 100644 --- a/hostnix/elmo/configuration.nix +++ b/hostnix/elmo/configuration.nix @@ -6,6 +6,7 @@ ./backup.nix ./bjj-booker.nix ./cgithub.nix + ./clippersnip.nix ./dns.nix ./dyndns.nix ./email.nix |
