From d8cdda91e3c8027ed8a057649b32e2a00d4abaf9 Mon Sep 17 00:00:00 2001 From: lassulus Date: Sun, 30 Jul 2023 17:22:00 +0200 Subject: reaktor2: add hotdog.r/bedger.json endpoint --- krebs/2configs/reaktor2.nix | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'krebs') diff --git a/krebs/2configs/reaktor2.nix b/krebs/2configs/reaktor2.nix index c357da1d7..0f7ab0adf 100644 --- a/krebs/2configs/reaktor2.nix +++ b/krebs/2configs/reaktor2.nix @@ -498,6 +498,36 @@ in { ''; }; + krebs.htgen.bedger = { + port = 8011; + user = { + name = "reaktor2"; + home = stateDir; + }; + script = ''. ${pkgs.writers.writeDash "bedger" '' + case "$Method" in + "GET") + printf 'HTTP/1.1 200 OK\r\n' + printf 'Connection: close\r\n' + printf '\r\n' + ${pkgs.hledger}/bin/hledger -f ${stateDir}/ledger bal -N -O json + exit + ;; + esac + ''}''; + }; + + services.nginx.virtualHosts."hotdog.r" = { + locations."/bedger.json".extraConfig = '' + proxy_set_header Host $host; + proxy_pass http://localhost:8011; + ''; + extraConfig = '' + add_header 'Access-Control-Allow-Origin' '*'; + add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS'; + ''; + }; + systemd.services.reaktor2-r.serviceConfig.DynamicUser = mkForce false; systemd.services.reaktor2-hackint.serviceConfig.DynamicUser = mkForce false; krebs.reaktor2 = { -- cgit v1.2.3