commit 91408e28a55e5af2baf0f0e3292743464d91e78e
parent 728faca3c66dc701ccd36309c80601ad31b481c8
Author: Leah (ctucx) <leah@ctu.cx>
Date: Thu, 27 Jan 2022 17:06:48 +0100
parent 728faca3c66dc701ccd36309c80601ad31b481c8
Author: Leah (ctucx) <leah@ctu.cx>
Date: Thu, 27 Jan 2022 17:06:48 +0100
machines/lollo/smarthome/smartied: serve departures localy
1 file changed, 41 insertions(+), 18 deletions(-)
M
|
59
+++++++++++++++++++++++++++++++++++++++++------------------
diff --git a/machines/lollo/smarthome/smartied.nix b/machines/lollo/smarthome/smartied.nix @@ -30,13 +30,25 @@ let }; }; + kvg-station-departures = pkgs.nimPackages.buildNimPackage { + pname = "kvg-kiel-station-departures"; + version = "0.1.0"; + nimBinOnly = true; + + src = pkgs.fetchgit { + url = "https://cgit.ctu.cx/kvg-kiel-station-departures"; + rev = "38c2dba0879635cede2e29051831dfe2c71c0f86"; + sha256 = "1v1hsxy47lv81pl86pgiq7pa61rr39jj78314qczvqq0igjz1frc"; + }; + }; + smartiePWA = import "${pkgs.fetchgit { url = "https://cgit.ctu.cx/smartie-pwa/"; - rev = "3fe40dfd8211f05751c3df98402eb2367636a6f7"; - sha256 = "1zvhgmbbfxgxjaq8wbw3b8k95h5p5rqk28g55av7rpxxgmkcmz7y"; + rev = "26a2737e4b08eb3d9252d00a07c9dd60a7743f7f"; + sha256 = "1qbr8iqbifa1b0854jbmm7zcaa5c0lrppn3g7rag37sa8cksgxjv"; }}" {}; - config = { + smartiedConfig = { devices = { "modbus-20" = { type = "RelayBoard"; @@ -265,7 +277,7 @@ let name = "Departures"; icon = "departure_board"; type = "departures"; - source = "https://f2k1.de/haltestellen.php"; + source = "/departures?stations=1505,2946,2187"; } { url = "fritzbox"; @@ -320,7 +332,7 @@ let }; }; - configFile = pkgs.writeText "smartied-config.json" (builtins.toJSON config); + configFile = pkgs.writeText "smartied-config.json" (builtins.toJSON smartiedConfig); in { @@ -340,22 +352,33 @@ in { }; }; - services.nginx = { - enable = true; - virtualHosts."home.ctu.cx" = { - enableACME = true; - forceSSL = true; - locations = { - "/" = { - root = smartiePWA; - index = "index.html"; - }; - "/ws" = { - proxyPass = "http://127.0.0.1:5000/ws"; - proxyWebsockets = true; + services = { + fcgiwrap.enable = true; + + nginx = { + enable = true; + virtualHosts."home.ctu.cx" = { + enableACME = true; + forceSSL = true; + locations = { + "/" = { + root = smartiePWA; + index = "index.html"; + }; + "/ws" = { + proxyPass = "http://127.0.0.1:5000/ws"; + proxyWebsockets = true; + }; + "/departures".extraConfig = '' + include "${pkgs.nginx}/conf/fastcgi_params"; + fastcgi_param SCRIPT_FILENAME "${kvg-station-departures}/bin/kvg_kiel_station_departures"; + fastcgi_param QUERY_STRING $args; + fastcgi_pass unix:${config.services.fcgiwrap.socketAddress}; + ''; }; }; }; + }; }