summaryrefslogtreecommitdiff
path: root/hostnix/elmo
diff options
context:
space:
mode:
Diffstat (limited to 'hostnix/elmo')
-rw-r--r--hostnix/elmo/clippersnip.nix64
-rw-r--r--hostnix/elmo/configuration.nix1
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