From 676a0e14413c1b9d16419e03b602688f5cf9852d Mon Sep 17 00:00:00 2001 From: Joe Mou Date: Wed, 15 Jul 2026 17:36:23 -0400 Subject: BJJ Booker --- hostnix/elmo/bjj-booker.nix | 49 ++++++++++++++++++++++++++++++++++++++++++ hostnix/elmo/configuration.nix | 1 + 2 files changed, 50 insertions(+) create mode 100644 hostnix/elmo/bjj-booker.nix (limited to 'hostnix/elmo') diff --git a/hostnix/elmo/bjj-booker.nix b/hostnix/elmo/bjj-booker.nix new file mode 100644 index 0000000..817940a --- /dev/null +++ b/hostnix/elmo/bjj-booker.nix @@ -0,0 +1,49 @@ +{ pkgs, ... }: + +{ + systemd.tmpfiles.rules = [ + "d /opt/bjj-booker 0755 joe users" + ]; + + systemd.sockets.bjj-booker = { + wantedBy = [ "sockets.target" ]; + socketConfig = { + ListenStream = "/run/bjj-booker/socket"; + SocketGroup = "nginx"; + SocketMode = "0660"; + }; + }; + + systemd.services.bjj-booker = { + requires = [ "bjj-booker.socket" ]; + after = [ "bjj-booker.socket" ]; + environment.GYMDESK_EMAIL = "nyc@mou.fo"; + serviceConfig = { + Type = "exec"; + DynamicUser = true; + WorkingDirectory = "/opt/bjj-booker"; + StateDirectory = "bjj-booker"; + LoadCredential = [ "GYMDESK_PASSWORD:/var/secrets/bjj-booker.password" ]; + }; + script = '' + export GYMDESK_PASSWORD=$(< $CREDENTIALS_DIRECTORY/GYMDESK_PASSWORD) + exec ${pkgs.nodejs-slim_24}/bin/node server.js + ''; + }; + + services.nginx.virtualHosts."bjj.mou.fo" = { + enableACME = true; + forceSSL = true; + locations."/" = { + proxyPass = "http://unix:/run/bjj-booker/socket"; + }; + locations."=/bookings.ics" = { + proxyPass = "http://unix:/run/bjj-booker/socket"; + extraConfig = '' + auth_request off; + ''; + }; + }; + + services.oauth2-proxy.nginx.virtualHosts."bjj.mou.fo" = { }; +} diff --git a/hostnix/elmo/configuration.nix b/hostnix/elmo/configuration.nix index 41a3ae9..a230b31 100644 --- a/hostnix/elmo/configuration.nix +++ b/hostnix/elmo/configuration.nix @@ -4,6 +4,7 @@ imports = [ ./acme.nix ./backup.nix + ./bjj-booker.nix ./cgithub.nix ./dns.nix ./dyndns.nix -- cgit v1.3.1